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

Example 15: Convert (0.3)  to binary.
                                   10
                             Fraction part     Integer part
              0.3 × 2  =  0.6     0.6              0
              0.6 × 2  =  1.2     0.2              1
              0.2 × 2  =  0.4     0.4              0
              0.4 × 2  =  0.8     0.8              0
              0.8  × 2  =  1.6    0.6              1
              0.6 × 2  =  1.2     0.2              1
              0.2  × 2  =  0.4    0.4              0
              0.4  × 2  =  0.8    0.8              0
              0.8  × 2  =  1.6    0.6              1
              (0.3)  = (0.010011001)
                   10
                  Recurring digits
            So, we can write, (0.3) as (0.0 1001 1001) if 9-bit accuracy of the fraction part is required, (0.3) as (0.0 1001
                                 10                 2                                                  10
            1001 100) if 12-bit accuracy of the fraction part is required, and (0.3) as (0.0 1001 1001 1001 1001 1001) if 21-bit
                     2                                                    10                                2
            accuracy of the fraction part is required.
            Similarly, the binary equivalent of (0.8)  is (0.110011001100110011)  to 18 decimal places as the digits '1100' are
                                               10
                                                                           2
            being repeated.
            The same method will apply when the fraction is represented as (p/q)  . Let us illustrate it on 3/7 .
                                                                                                   10
                                                                          10
            Example 16: Convert 3/7 to an equivalent binary number.
                                  10
                             Fraction part     Integer part
              (3/7) × 2 = 6/7     6/7              0
              (6/7) × 2 = 12/7    5/7              1
              (5/7) × 2 = 10/7    3/7              1
              (3/7) × 2 = 6/7     6/7              0
              (6/7) × 2 = 12/7    5/7              1
              (5/7) × 2 = 10/7    3/7              1

              3/7  = (0.011011)  Recurring digits
                 10
                               2
            To obtain the binary representation of a decimal number having an integer and the fractional part, then apply the
            following steps:
            1.  Convert the integer part to an equivalent binary number (say, a)
            2.  Convert the fraction part between 0 and 1 to an equivalent binary number between 0 and 1 (say, b).
            3.  Write the binary representation of the integer part, followed by the binary representation of the fraction part.
            Example 17: Convert (101.25) to its equivalent binary number.
                                      10
            Whole number part - 101

                2    101        Remainder
                2     50           1
                2     25           0

                2     12           1
                                              = (1100101)
                2      6           0                     2

                2      3           0
                2      1           1

                       0           1


                                                                            Number Systems and Encoding Schemes  49
   46   47   48   49   50   51   52   53   54   55   56