Page 45 - Computer Science Class 11 With Functions
P. 45

2
                           1
                               2
                                                                    0
                                                             1
                                                      2
                                              0
                                      1
                = (8) × 1 + 8 × (2 × 1 + 2 × 0 + 2 × 1) + (2 × 1 + 2 × 1 + 2 × 0)
                                                            1
                                       1
                                                                   0
                   3 2
                                                     2
                                              0
                               2
                           3
                = (2 ) × 1 +2 × (2 × 1 + 2 × 0 + 2 × 1) +2 × 1 + 2 × 1 + 2 × 0
                                      3
                                          1
                                                              1
                   3 2
                                                       2
                               2
                                                                     0
                            3
                                                3
                = (2 )  × 1 + 2 × 2 × 1 +2 × 2 × 0 +2 × 1 +2 × 1 + 2 × 1 + 2 × 0
                  6
                         5
                                                     1
                                              2
                                                            0
                                4
                                       3
                = 2 × 1 + 2 × 1 + 2 × 0 + 2 × 1 +2 × 1 + 2 × 1 + 2 × 0
            Thus, we find (156)  = (1101110) 2
                             8
                    Find binary representation of (34) , (450) , and (301) .
                                                              8
                                               8
                                                     8
            Binary to Hexadecimal Conversion
            To convert a number from binary to hexadecimal, the sequence of steps is as follows:
            1.   If the number of digits in the binary number is not a multiple of four, include the number with sufficient number
                leading zeros to make the number of digits a multiple of four. For example, if the given number is (111011100) ,
                                                                                                                   2
                we note that it has nine digits. We prefix it with three zeros to make its representation twelve (12=4x3) bits long:
                (000111011100) .
                              2
            2.  Beginning from the leftmost (or rightmost) digit, form groups of four bits.
            3.   Replace each 4-bit group by its corresponding hexadecimal digit. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 14, 15 as
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F respectively.
            Example 9: Convert (111011100)  to its equivalent hexadecimal number.
                                          2
                        added three 0s
               0 0 0 1  1  1  0  1 1  1  0  0
                 1         D        C
                (111011100)  = (1DC) 16
                           2
            To understand why the above method works, let us examine the following computations:
                (111011100)  2
                                                                  1
                                6
                = 2 × 1 + 2 × 1 + 2 x1 + 2 × 0 +2 × 1 + 2 × 1 + 2 x 1 + 2 × 0 + 2 × 0
                                                           2
                         7
                                                    3
                                       5
                                                                         0
                                             4
                  8
                                                        3
                                                 4
                                                               2
                                          2
                                      4
                               3
                            4
                   4 2
                = (2 )  × 1 + 2 × 2 × 1 +2 × 2 × 1 + 2 × 1 + 2 × 1 + 2 × 1
                                                                        1
                   4 2
                                                            4
                                                                 2
                                                     0
                           4
                                                                                                    2
                                                                                      4
                                       2
                                                                               0
                                                                                             3
                                              1
                               3
                = (2 ) × 1 +2 × (2 × 1 + 2 × 0 + 2 × 0 + 2 × 0) + 2 × (2 × 1 + 2 × 0 + 2 × 0) + 2 × 1 + 2 × 1 + 2 × 1
                                                                                          1
                                                                                  0
                                                                           1
                                                                    2
                                                               1
                                                                                                   0
                     2
                             1
                                                1
                                                                                                              2
                                 3
                                                       0
                                                                                                       3
                                        2
                = (16) × 1 + 16 × (2 × 1 + 2 × 0 + 2 × 0 + 2 × 0) + 16 × (2 × 1 + 2 × 0 + 2 × 0) + 16 × 1 + 16 × (2 × 1 + 2 x 1)
                = 16 × 1 + 16 × (13) + 16 × (12)
                                      0
                   2
                            1
                = (1DC) 16
            Hexadecimal to binary
            To  convert  a  hexadecimal  number  to  binary,  replace  each  hexadecimal  digit  by  its  4-bit  expression  as  shown  in
            example 10.
            Example 10: (1DC)  to binary
                            16
                  1          D         C
                  ↓          ↓         ↓
                 0001      1101       1100
                (1DC)  = (000111011100) 2
                     16
                     = (111011100)
                                  2
                                                                            Number Systems and Encoding Schemes  43
   40   41   42   43   44   45   46   47   48   49   50