Page 45 - Computer Science Class 11 Without Functions
P. 45
To understand why the above method works, let us examine the following computations:
(156) 8
2
1
= 8 × (1) + 8 × (5) + (6)
0
0
1
2
2
= 8 × 1 + 8 × (2 × 1 + 2 × 0 + 2 × 1) + (2 × 1 + 2 × 1 + 2 × 0)
1
2
1
2
1
2
0
2
0
1
1
= (8) × 1 + 8 × (2 × 1 + 2 × 0 + 2 × 1) + (2 × 1 + 2 × 1 + 2 × 0)
0
3 2
0
1
2
3
2
1
= (2 ) × 1 +2 × (2 × 1 + 2 × 0 + 2 × 1) +2 × 1 + 2 × 1 + 2 × 0
2
3
0
1
3
1
3 2
= (2 ) × 1 + 2 × 2 × 1 +2 × 2 × 0 +2 × 1 +2 × 1 + 2 × 1 + 2 × 0
3
2
3
0
4
5
6
2
1
= 2 × 1 + 2 × 1 + 2 × 0 + 2 × 1 +2 × 1 + 2 × 1 + 2 × 0
Thus, we find (156) = (1101110) 2
8
Find binary representation of (34) , (450) , and (301) .
8
8
8
Binary to Hexadecimal Conversion
To convert a number from binary to hexadecimal, the sequence of steps is as follows:
1. If the number of digits in the binary number is not a multiple of four, include the number with sufficient number
leading zeros to make the number of digits a multiple of four. For example, if the given number is (111011100) ,
2
we note that it has nine digits. We prefix it with three zeros to make its representation twelve (12=4x3) bits long:
(000111011100) .
2
2. Beginning from the leftmost (or rightmost) digit, form groups of four bits.
3. Replace each 4-bit group by its corresponding hexadecimal digit. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 14, 15 as
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F respectively.
Example 9: Convert (111011100) to its equivalent hexadecimal number.
2
added three 0s
0 0 0 1 1 1 0 1 1 1 0 0
1 D C
(111011100) = (1DC) 16
2
To understand why the above method works, let us examine the following computations:
(111011100) 2
8
4
1
0
6
3
2
= 2 × 1 + 2 × 1 + 2 x1 + 2 × 0 +2 × 1 + 2 × 1 + 2 x 1 + 2 × 0 + 2 × 0
7
5
3
3
4 2
4
2
2
4
4
= (2 ) × 1 + 2 × 2 × 1 +2 × 2 × 1 + 2 × 1 + 2 × 1 + 2 × 1
4
2
2
3
1
0
4
1
3
2
4
0
4 2
= (2 ) × 1 +2 × (2 × 1 + 2 × 0 + 2 × 0 + 2 × 0) + 2 × (2 × 1 + 2 × 0 + 2 × 0) + 2 × 1 + 2 × 1 + 2 × 1
= (16) × 1 + 16 × (2 × 1 + 2 × 0 + 2 × 0 + 2 × 0) + 16 × (2 × 1 + 2 × 0 + 2 × 0) + 16 × 1 + 16 × (2 × 1 + 2 x 1)
0
2
2
0
1
1
2
3
0
1
2
3
1
1
= 16 × 1 + 16 × (13) + 16 × (12)
1
2
0
= (1DC)
16
Hexadecimal to binary
To convert a hexadecimal number to binary, replace each hexadecimal digit by its 4-bit expression as shown in
example 10.
Number Systems and Encoding Schemes 43

