Page 26 - computer science (868) class 11
P. 26
Example 2: Convert (4AB.2) to binary.
16
Answer:
4 10(A) 11(B) . 2
0100 1010 1011 . 0010
Binary equivalent is (0100 1010 1011.0010) 2
After removing leading 0s in the integer part and trailing 0s in the fractional part
= (10010101011.001)
2
1.2.11 Octal to Hexadecimal and Hexadecimal to Octal
The steps to be followed are:
1. To convert octal to hexadecimal, first convert octal to binary and binary to hexadecimal by the steps mentioned
above.
8 (2 ) 4 (2 ) 2 (2 ) 1 (2 ) Hexa
3
0
1
2
2. Similarly, to convert hexadecimal to octal, convert hexadecimal to binary and the binary to octal as shown
0 1 0 1 0 × 8 + 1 × 4 + 0 × 2 + 1 × 1 = 5 above.
0 1 0 0 0 × 8 + 1 × 4 + 0 × 2 + 0 × 1 = 4
1 1 1 1 1 × 8 + 1 × 4 + 1 × 2 + 1 × 1 = 15 Note: The above conversion can be done by first converting number of one base to decimal and then the
decimal number to number of another base. Previous mentioned method has been followed in this book
as it makes calculation simpler.
Example 1: Convert (2517) to hexadecimal.
8
1
2
0
Answer: Converting Octal to Binary first 4 (2 ) 2 (2 ) 1 (2 ) Octal
2 5 1 7 0 1 0 0 × 4 + 1 × 2 + 0 × 1 = 2
010 101 001 111 1 0 1 1 × 4 + 0 × 2 + 1 × 1 = 5
0 0 1 0 × 4 + 0 × 2 + 1 × 1 = 1
Binary equivalent is (010101001111) 1 1 1 1 × 4 + 1 × 2 + 1 × 1 = 7
2
Converting Binary to Hexadecimal after Grouping 0101 0100 1111.
0
2
3
1
0101 0100 1111 8 (2 ) 4 (2 ) 2 (2 ) 1 (2 ) Hexa
5 4 15(F) 0 1 0 1 0 x 8 + 1 x 4 + 0 x 2 + 1 x 1 = 5
0 1 0 0 0 x 8 + 1 x 4 + 0 x 2 + 0 x 1 = 4
1 1 1 1 1 x 8 + 1 x 4 + 1 x 2 + 1 x 1 =15
(54F) 16
Example 2: Convert (621.04) to hexadecimal.
8
Answer: Converting Octal to Binary first
2
1
0
6 2 1 . 0 4 4 (2 ) 2 (2 ) 1 (2 ) Octal
110 010 001 . 000 100 1 1 0 1 × 4 + 1 × 2 + 0 × 1 = 6
Binary equivalent is (110 010001.000100) 2 0 1 0 0 × 4 + 1 × 2 + 0 × 1 = 2
Grouping 4 bits 0 0 1 0 × 4 + 0 × 2 + 1 × 1 = 1
Converting Binary to Hexadecimal after ignoring 0 0 0 0 × 4 + 0 × 2 + 0 × 1 = 0
trailing 0s in fractional part and adding 3 0s 1 0 0 1 × 4 + 0 × 2 + 0 × 1 = 4
before 1
2424 Touchpad Computer Science-XI

