Page 24 - Cs_withBlue_J_C11_Flipbook
P. 24

1.2.8 Binary to Hexadecimal
              The steps to be followed are:
              1.  Group all the 1s and 0s in the binary number in 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.  Write 8 (2 ), 4 (2 ), 2 (2 ), 1 (2 ) above each set of four bits, multiply it with the corresponding bit and add the
                          3
                                2
                                             0
                                       1
                 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 group 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
                                           3 2 1 0
                                                    3 2 1 0
                                                            3 2 1 0
                                          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
                                                  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
                                                                                          0
                                                                                     1
              Adding 2 0s before 10 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 by 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
                    0
                           1
                                  2
              = 7 x 8  + 1 x 8  + 5 x 8  + 2 x 8 3
                2222  Touchpad Computer Science-XI
   19   20   21   22   23   24   25   26   27   28   29