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

4.  Repeat steps 2 and 3 until the fraction becomes zero.
          5.  Write the integer parts from the top (computed first) to the bottom (computed last).
          To understand why the above methods works, examine the following computations: 0.25
              -1
          = 2  × 0.5
              -1
          = 2  × 0 + 2  × 1
                     -2
          = (0.01) 2
        Example 13: Convert (.25)  to an equivalent binary equivalent.
                               10
                                Fraction part      Integer part
          0.25 × 2 = 0.5             0.5                0
          0.5 × 2   = 1.0            0.0                1
          (0.25) 10   = (0.01) 2
        To understand why the above methods works, examine the following computations: 0.40625

               -1
            = 2  × 0.8125
               -1
                      -2
            = 2  × 0 + 2  × (1 + 0.625)
                      -2
                              -2
               -1
            = 2  × 0 + 2  × 1 + 2  × 0.625
               -1
                      -2
                              -3
            = 2  × 0 + 2  × 1 + 2  × (1 + 0.25)
                              -3
            = 2  × 0 + 2  × 1 + 2  × 1 + 2  × 0.25
                                      -3
                      -2
               -1
               -1
                                             -4
                      -2
                                      -4
                              -3
            = 2  × 0 + 2  × 1 + 2  × 1 + 2  × 0 + 2  × 0.5
                              -3
                      -2
                                     -4
                                            -5
               -1
            = 2  × 0+ 2  × 1 + 2  × 1+ 2  × 0 + 2  × 1
            = (0.01101)
                      2
        Example 14: Convert (0.40625)  to an equivalent binary number:
                                    10
                                         Fraction part       Integer part
          0.40625 × 2   = 0.8125            0.8125               0
          0.8125 × 2     = 1.625             0.625               1
          0.625   × 2     = 1.25             0.25                1
          0.25     × 2     = 0.5             0.5                 0
          0.5       × 2     = 1.0            0.0                 1
          (0.40625)  = (0.01101) 2
                   10
        The above method works for fractions which can be expressed as the sum of negative powers of 2, for example,
                          1
         1  +   +   1  ,   +   +   1  , and so on. Such fractions are known as terminating fractions. However, in the case of
                     1
             1
         2   8   16 4     8   64
        non-terminating fractions, the fractional part never becomes zero. So, in the case of non-terminating fractions, repeat
        steps 2 and 3 enough times to get the required number of bits after the radix point. For example, we may write
        0.3 = (0.0 1001 1001 …) as shown below:
        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

          48   Touchpad Computer Science-XI
   45   46   47   48   49   50   51   52   53   54   55