Lecture 3 (Number System Conversion)
Lecture 3 (Number System Conversion)
Example: (13)10
Quotient Remainder Coefficient
13/ 2 = 6 1 a0 = 1 LSB
6 /2= 3 0 a1 = 0
3 /2= 1 1 a2 = 1
1 /2= 0 1 a3 = 1
Answer: (13)10 = (a3 a2 a1 a0)2 = (1101)2 MSB
MSB LSB
14 December 2022 4
Decimal (fraction ) to Binary Conversion
1. Multiply the number by the ‘Base’ (=2).
2. Take the integer (either 0 or 1) as a coefficient.
3. Take the resultant fraction and repeat the multiplication.
Example: (0.625)10
Integer Fraction Coefficient
a-1 = 1 MSB
0.625 * 2 = 1 . 25
0.25 * 2 = 0 . 5 a-2 = 0
0.5 *2= 1 . 0 a-3 = 1
LSB
Answer: (0.625)10 = (0.a-1 a-2 a-3)2 = (0.101)2
MSB LSB
14 December 2022 5
Binary to Decimal Conversion
Example: Integer Binary number 1101101 where 20 =1
1 1 0 1 1 0 1
6 5 4 3 2 1 0 6 5 4 3 2 1 0
2 2 2 2 2 2 2 = 2 *1+ 2 *1+ 2 *0+ 2 *1+ 2 *1+ 2 *0+ 2 *1
0. 1 0 1 1
0.5+0+0.125+0.0625=0.6875 ➔(0.6875)10
14 December 2022 6
Binary to Decimal Conversion
(101.011)2 =
=1 * 22 +0 * 21 + 1 * 20 + 0 x 2-1 + 1 x 2-2 + 1 x 2-3
=1 x 4 + 0 x 2 + 1 x 1 + 0 x 0.5 +1 x 0.25 +1 x 0.125
= 4 + 0 + 1 + 0 + 0.25 + 0.125
=5.375
7
Decimal to Octal Conversion
Example: (175)10 Quotient Remainder Coefficient
175 / 8 = 21 7 a0 = 7
21 / 8 = 2 5 a1 = 5
2 /8= 0 2 a2 = 2
Answer: (175)10 = (a2 a1 a0)8 = (257)8
Example: (0.3125)10
Integer Fraction Coefficient
0.3125 * 8 = 2 . 5 a-1 = 2
0.5 *8= 4 . 0 a-2 = 4
Answer: (0.3125)10 = (0.a-1 a-2 a-3)8 = (0.24)8
Decimal Fraction to Octal Fraction
Example: Convert the given decimal fraction numbers to octal, 0.91:
(0.91)10 = (?)8
9
Octal to Decimal Conversion
Examples: (176)8
2 1 0
(176) 8 = 1*8 + 7*8 + 6*8
= 64 + 56 + 6 = (126) 10
• (2374) 8
3 2 1 0
(2374) 8 = 2*8 + 3*8 + 7*8 + 4*8
• (52.3)8
1 0 -1
= 5 *8 + 2 *8 + 3 *8
= 5*8 + 2*1 + 3/8
= 40 + 2 + 0.375 = (42.375)10
• (512.74) 8
2 1 0 -1 -2
5 *8 + 1 *8 + 2 *8 + 7 *8 + 4 *8
= 5*64 + 1*8 + 2*1 + 7/8 + 4/64
= 320 + 8 + 2 + 0.875 + 0.0625 = (330.9375)10
Decimal to Hexadecimal Conversion
Example: Convert (3567)10 to Hexadecimal
LSD
13
Hexadecimal to Decimal Conversion
14 December 2022 14
Binary to Octal Conversion
( 6 3 ) 8 = (63)8
(0 1 1 1 1 1. 0 1 1 )2
( 3 7 . 3 ) 8 = (37.3)8
14 December 2022 15
Binary to Octal Conversion
8 = 23
Octal Binary
Each group of 3 bits represents an octal digit 0 000
Assume Zeros 1 001
Example:
2 010
( 1 0 1 1 0 . 0 1 )2 3 011
4 100
5 101
( 2 6 . 2 )8 6 110
7 111
Works both ways (Binary to Octal & Octal to Binary)
14 December 2022 16
Binary to Octal Conversion
Examples: Assume Zero
( 1 0 1 0 0 )2
( 2 4 ) 8 = (24)8
Assume Zeros
( 1 1 1 0 1. 1 1 )2
( 3 5 . 6 ) 8 = (35.6)8
- Works both ways (Binary to Octal & Octal to Binary)
Octal to Binary Conversion
14 December 2022 18
Binary to Hexadecimal Conversion
16 = 24 Hex Binary
0 0000
Each group of 4 bits represents a hexadecimal digit 1 0001
2 0010
3 0011
Assume Zeros
Example: 4 0100
5 0101
6 0110
( 1 0 1 1 0 . 0 1 )2 7 0111
8 1000
9 1001
A 1010
B 1011
(1 6 . 4 )16 C
D
1100
1101
E 1110
F 1111
Works both ways (Binary to Hex & Hex to Binary)
14 December 2022 19
Hexadecimal to Binary Conversion
14 December 2022 20
Octal to Hexadecimal Conversion
Convert to Binary as an intermediate step
Example: ( 2 6 . 2 )8
( 0 1 0 1 1 0 . 0 1 0 )2
(1 6 . 4 )16