Page 50 - Computer Science Class 11 Without Functions
P. 50
Decimal to Binary Conversion
To convert a decimal fraction between 0 and 1 (for example, (.25) and (0.40625) ) to binary, follow the steps given
10
10
below:
1. Multiply the fraction by 2.
2. Note the integer part of the product (0 or 1).
3. Multiply by two; the fraction left over after removing the integer part from the product.
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
-2
-1
= 2 × 0 + 2 × 1
= (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
-2
-1
= 2 × 0 + 2 × (1 + 0.625)
= 2 × 0 + 2 × 1 + 2 × 0.625
-2
-2
-1
-2
-1
-3
= 2 × 0 + 2 × 1 + 2 × (1 + 0.25)
-1
-3
-3
= 2 × 0 + 2 × 1 + 2 × 1 + 2 × 0.25
-2
= 2 × 0 + 2 × 1 + 2 × 1 + 2 × 0 + 2 × 0.5
-4
-1
-2
-4
-3
-2
-3
-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)
10 2
The above method works for fractions which can be expressed as the sum of negative powers of 2, for example,
1 + + 1 , + + 1 , and so on. Such fractions are known as terminating fractions. However, in the case of
1
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:
48 Touchpad Computer Science-XI

