Page 26 - ComputerScience_Class_11
P. 26
1.2.8 Binary to Hexadecimal
The steps to be followed are:
1. Group all the 1s and 0s in the binary number into sets of four, 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 first digit if it contains less than 4 bits to make a set of
four. Similarly, for the fractional part, add 0s to the right if necessary, to make a set of four.
3
2
0
1
3. Write 8 (2 ), 4 (2 ), 2 (2 ), 1 (2 ) above each set of four bits, multiply each by the corresponding bit and add the
products to get the hexadecimal equivalent of each set.
4. Repeat the process for the other sets.
5. Arrange the newly converted hexadecimal digits together to form the final result.
Example 1: Convert (110101011) to hexadecimal.
2
Answer: Making groups of 4 bits 1 1010 1011 3 2 1 0
Adding 3 0s before 1 to get 0001 1010 1011 8 (2 ) 4 (2 ) 2 (2 ) 1 (2 ) Octal
↓ ↓ ↓ 0 0 0 1 0 × 8 + 0 × 4 + 0 × 2 + 1 × 1 = 1
0001 1010 1011 1 0 1 0 1 × 8 + 0 × 4 + 1 × 2 + 0 × 1 = 10
2 2 2 2 2 2 2 2 2 2 2 2 1 0 1 1 1 × 8 + 0 × 4 + 1 × 2 + 1 × 1 = 11
3 2 1 0
3 2 1 0
3 2 1 0
0001 1010 1011
1 10(A) 11(B)
(110101011) = (1AB) 16
2
Example 2: Convert (101101.0101) to hexadecimal.
2
Answer: Making group of 4 bits 10 1101 . 0101 8 (2 ) 4 (2 ) 2 (2 ) 1 (2 ) Hexa
3
2
1
0
Adding 2 0s before 1 0 to get 0010 1101 . 0101 0 0 1 0 0 × 8 + 0 × 4 + 1 × 2 + 0 × 1 = 2
↓ ↓ ↓
0010 1101 0101 1 1 0 1 1 × 8 + 1 × 4 + 0 × 2 + 1 × 1 = 13
2 2 2 2 2 2 2 2 2 2 2 2 0 1 0 1 0 × 8 + 1 × 4 + 0 × 2 + 1 × 1 = 5
3 2 1 0
3 2 1 0
3 2 1 0
0010 1101 . 0101
2 13(D) . 5
(101101.0101) = (2D.5) 16
2
1.2.9 Octal to Binary
We can convert the octal number into binary in two ways:
a. converting octal into decimal first and then decimal into binary
b. converting octal into binary with the help of the table.
The steps to be followed in the second method are:
1. Convert each octal digit to its binary equivalent with the help of the table given on Pg-16 that shows relationship
among different number systems.
2. Arrange the newly converted binary digits together.
3. Remove leading 0s in the integer part and trailing 0s in the fractional part to get the final binary equivalent.
Example 1: Convert (2517) to binary.
8
Answer:
Method 1:
Converting (2517) into decimal
8
1
0
= 7 x 8 + 1 x 8 + 5 x 8 + 2 x 8 3
2
24 Touchpad Computer Science (Ver. 3.0)-XI

