Page 44 - Computer Science Class 11 Without Functions
P. 44
Find decimal equivalent of hexadecimal numbers 32 and 100 .
16
16
Binary to Octal Conversion
To convert a number from binary to octal, apply the following steps:
1. If the number of digits in the binary number is not a multiple of three, prefix the number with leading zeros to
make the number of digits a multiple of three. For example, if the given number is (1101110) , we note that it has
2
seven digits. We prefix it with two zeros to make its representation nine (9=3x3) bits long: (001101110) .
2
2. Beginning from the leftmost (or rightmost) digit, form groups of three bits.
3. Replace each 3-bit group with an equivalent octal digit.
Example 7: Convert (1101110) to its equivalent octal number.
2
two 0s added to make a 3-bit group
0 0 1 1 0 1 1 1 0
1 5 6
(1101110) = (156) 8
2
To understand why the above method works, let us examine the following computations:
(1101110) 2
0
5
4
1
6
3
2
= 2 × 1 + 2 × 1 + 2 × 0 + 2 × 1 +2 × 1 + 2 × 1 + 2 x 0
3
0
3 2
= (2 ) × 1 + 2 × 2 × 1 +2 × 2 × 0 +2 × 2 × 1 +2 × 1 + 2 × 1 + 2 × 0
3
3
2
1
0
1
2
0
1
3
3 2
0
1
2
2
= (2 ) × 1 +2 × (2 × 1 + 2 × 0 + 2 × 1) + (2 × 1 + 2 × 1 + 2 × 0)
2
0
2
2
0
1
1
1
= (8) × 1 + 8 × (2 × 1 + 2 × 0 + 2 × 1) + 8⁰ × (2 × 1 + 2 × 1 + 2 × 0)
1
2
= 8 × 1 + 8 × (4 + 0 + 1) + 8⁰ × (4 + 2 + 0)
= 8 × 1 + 8 × 5 + 8⁰ × 6
2
1
= (156) 8
(1101110) = (156) 8
2
Alternatively, to convert a binary number to its octal representation, you may first convert it to an equivalent decimal
number and then convert the decimal number to an equivalent octal number.
Find octal representation of (1111) , (11000) , and (101100) .
2
2
2
Octal to Binary Conversion
To convert an octal number to binary, replace each digit with an equivalent binary representation, as shown in example
8 below.
Example 8: Convert (156) to its equivalent binary number.
8
1 5 6
↓ ↓ ↓
001 101 110
(156) = (001101110)
8 2
(156) = (1101110) 2
8
42 Touchpad Computer Science-XI

