Page 23 - computer science (868) class 11
P. 23
Example 1: Convert (A6D9) to decimal.
16
Answer: 3 2 1 0 Place value
A 6 D 9 Digits
2
3
= 10 × 16 + 6 × 16 + 13 × 16 + 9 × 16 0
1
= 40960 + 1536 + 208 + 9
= (42713)
10
Example 2: Convert (0.C82) to decimal.
16
Answer: 0 -1 -2 -3
0 . C 8 2
-2
= 12 × 16 + 8 × 16 + 2 × 16 -3
-1
= 3/4 + 1/32 + 1/2048
= (0.7817)
10
1.2.7 Binary to Octal
The steps to be followed are:
1. Group all the 1s and 0s in the binary number in sets of three, starting from the left of the binary point for the integer
part and right of the point for the fractional part.
2. For the integer part, add necessary zeros to the left of the MSB if it contains less than 3 bits to make a set of three.
Similarly, for the fractional part, add 0s to the right if necessary, to make a set of three.
0
2
3. Write 4 (2 ), 2 (2 ), and 1 (2 ) above each set of three bits, multiply it with the corresponding bit and add the
1
products to get the octal equivalent of each set.
4. Repeat the process for the other sets.
5. Arrange the newly converted octal digits together to form the final result.
Example 1: Convert (1101011) to octal.
2
Answer: On grouping 3 bits from LSB 1 101 011
2
0
1
In leftmost 1 adding two 0s, we get 001 101 011 4 (2 ) 2 (2 ) 1 (2 ) Octal
↓ ↓ ↓ 0 0 1 0 × 4 + 0 × 2 + 1 × 1 = 1
001 101 011 1 0 1 1 × 4 + 0 × 2 + 1 × 1 = 5
2 2 2 0 2 2 2 0 2 2 2 0 0 1 1 0 × 4 + 1 × 2 + 1 × 1 = 3
1
2
2
1
2
1
001 101 011
1 5 3
(1101011) = (153)
2 8
Example 2: Convert (10101.0101) to octal.
2
Answer: Making sets of 3 bits 10 101 . 010 1 4 (2 ) 2 (2 ) 1 (2 ) Octal
1
0
2
Adding one 0 before 10 (integer 010 101 . 010 100 0 1 0 0 × 4 + 1 × 2 + 0 × 1 = 2
part), and two 0s after 1 ↓ ↓ ↓ 1 0 1 1 × 4 + 0 × 2 + 1 × 1 = 5
(fractional part), we get 010 101 010 100
2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 0 1 0 0 × 4 + 1 × 2 + 0 × 1 = 2
2 1 0
2 1 0
2 1 0
1 0 0 1 × 4 + 0 × 2 + 0 × 1 = 4
010 101 . 010 100
2 5 . 2 4
(10101.0101) = (25.24) 8
2
21
Numbers 21

