Page 46 - Computer Science Class 11 Without Functions
P. 46

Example 10: (1DC)  to binary
                         16
               1         D          C
               ↓         ↓          ↓
             0001       1101      1100
            (1DC)  = (000111011100) 2
                 16
                 = (111011100) 2

        To understand why the above method works, let us examine the following computations:
            (1DC)
                 16
                                   0
                2
                        1
            = 16 × 1 + 16 × (13) + 16 × (12)
                                                           3
                                            1
                 2
                                                   0
                                     2
                              3
                                                                  2
            = (16) × 1 + 16 × (2 × 1 + 2 × 1 + 2 × 0 + 2 × 1) + (2 × 1 + 2 × 1 + 2 × 0 + 2 × 0)
                                                                         1
                                                                                0
                         1
                                          1
               4 2
                                                 0
            = (2 ) × 1 +2 × (2 × 1 + 2 × 1 + 2 × 0 + 2 × 1) + (2 × 1 + 2 × 1 + 2 × 0 + 2 × 0)
                            3
                                                                2
                                                                       1
                                                                              0
                                   2
                       4
                                                         3
                        4
                                  4
                            3
                                      2
                                                        4
                                                                                 1
                                                                          2
                                                                   3
                                                            0
               4 2
            = (2 )  × 1 + 2 × 2 × 1 +2 × 2 × 1 + 2 × 2 × 0 + 2 × 2 × 1 + 2 × 1 + 2 × 1 + 2 × 0 + 2 × 0
                                             4
                                                                                        0
                                                 1
                                                                       0
                                    5
                                           4
                                                  3
                                                                1
                                                         2
               8
                             6
                      7
            = 2 × 1 + 2 × 1 + 2 × 1 + 2 × 0 + 2 × 1 + 2 × 1 + 2 × 1 + 2 × 0 + 2 × 0
        Thus, (1DC) = (111011100)
                  16              2
                 Find binary representation of (34) , (6D) and (12F) .
                                           16    16        16
        Octal to Hexadecimal Conversion
        To convert an octal number to hexadecimal or vice versa, convert the number to an equivalent number in binary or
        decimal and then to hexadecimal.
        Example 11: Convert (347)  to its equivalent hexadecimal number.
                                8
        Step 1: Octal to Binary
               3         4          7
               ↓         ↓          ↓
              011       100        111
            (347)  = (11100111) 2
                 8
        Step 2: Binary to hexadecimal
             1   1   1   0  0   1   1   1
                 E           7
            (11100111)  = (E7) 16
                      2
            Therefore (347)  = (E7) 16
                          8
        Alternatively,  you  may  first  convert  the  octal  number  to  its  decimal  equivalent  and  then  find  the  hexadecimal
        representation of the decimal number.
                 Find hexadecimal representation of (34) , (15) and (50) .
                                                8    8       8
        Hexadecimal to Octal Conversion
        First, convert the hexadecimal number to an equivalent binary number and then convert the binary number to an octal
        number, as shown in example 12.
          44   Touchpad Computer Science-XI
   41   42   43   44   45   46   47   48   49   50   51