Docsity

Number Conversion - Computer Fundamentals - Lecture Slides, Slides of Computer Science

Partial preview of the text

Download Number Conversion - Computer Fundamentals - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

TOPICS

• Octal

• Hexadecimal

• Number conversion

Other Number Systems

• Octal and hex are a convenient way to represent

binary numbers, as used by computers.

• Computer mechanics often need to write out

binary quantities, but in practice writing out a

binary number such as

Octal Number Systems

• Base = 8 or ‘o’ or ‘Oct’

• 8 symbols: { 0, 1, 2, 3, 4, 5, 6, 7}

• Example 123, 567, 7654 etc

987 This is incorrect why?

• How to represent a Decimal Number using a

Octal Number System?

Octal Number Systems

• Repeated Division by 8

  • Example

Divide-by -8 Quotient Remainder Octal digit 213 / 8 26 / 8 3 / 8

Lower digit = 5 Second digit = Third digit =

Answer = 325

Octal Number Systems

• How to convert 325 8 back to Decimal?

  • Consider the above number

3 x 8^2 + 2 x 8 1 + 5 x 8 0 = 3 x 64 + 2 x 8 + 5 x 1 = 192 +16 + 5 = 213

Digit 1

Digit 3 Digit 2

Octal Number Systems

• Example Convert 611 8

  • Consider the above number

6 x 8^2 + 1 x 8 1 + 1 x 8 0 = 6 x 64 + 1 x 8 + 1 x 1 = 384 + 8 + 1 = 393

Digit 1

Digit 3 Digit 2

Hexadecimal Number

Systems

• Base = 16 or ‘H’ or ‘Hex’

16 symbols: { 0, 1, 2, 3, 4, 5, 6, 7,8,9 }

{ 10=A, 11=B, 12=C, 13=D, 14=E, 15= F}

Hexadecimal Number

Systems

• {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F} It uses 6

Letters!

• Example AB12, 876F, FFFF etc

• How to represent a Decimal Number using a

Hexadecimal Number System?

Hex Number Systems

• How to convert D5 16 back to Decimal?

  • Use this table and multiply the digits with the position

values

Digit 8

Digit 7

Digit 6

Digit 5

Digit 4

Digit 3

Digit 2

Digit 1 167 166 165 164 163 162 161 160

Hex Number Systems

• How to convert D5 16 back to Decimal?

  • Consider the above number

D 5 (16)

D x 16 1 + 5 x 16 0 = 13 x 16 + 5 x 1 = 208 + 5 = 213

Digit 1

Digit 2

Binary Number Systems

• And, if you have three bits, then you can use them

to represent eight unique states:

These have a perfect correspondence to Octal

000 = Octal 0 100 = Octal 4

001 = Octal 1 101 = Octal 5

010 = Octal 2 110 = Octal 6

011 = Octal 3 111 = Octal 7

Binary Number Systems

• With every bit you add, you double the number of

states you can represent. Therefore, the expression

for the number of states with n bits is 2 n. Most

computers operate on information in groups of 8

bits,

Binary Number Systems

, but in practice the most common scheme is:

0000 = decimal 00 hex 0 1000 = decimal 08 hex 8

0001 = decimal 01 hex 1 1001 = decimal 09 hex 9

0010 = decimal 02 hex 2 1010 = decimal 10 hex A

0011 = decimal 03 hex 3 1011 = decimal 11 hex B

0100 = decimal 04 hex 4 1100 = decimal 12 hex C

0101 = decimal 05 hex 5 1101 = decimal 13 hex D

0110 = decimal 06 hex 6 1110 = decimal 14 hex E

0111 = decimal 07 hex 7 1111 = decimal 15 hex F

These have perfect correspondence to Hex

Convert Binary to Hex

• Group into 4's starting at least significant

symbol (if the number of bits is not evenly

divisible by 4, then add 0's at the most

significant end)

• write 1 hex digit for each group