next up previous
Next: Approximate Values Up: Number Systems Previous: Fractions

Conversion of Fractions

Let F be a proper decimal fraction. The binary representation of F is:

displaymath2698

The most significant bit of F, tex2html_wrap_inline2704 , may be obtained by multiplying F by 2:

displaymath2699

The product 2F is the sum of tex2html_wrap_inline2704 and a proper fraction. If 2F tex2html_wrap_inline2708 1 then tex2html_wrap_inline2704 = 1. Otherwise tex2html_wrap_inline2704 = 0.

After tex2html_wrap_inline2704 is determined, the process may be repeated on the resulting proper fraction to determine the other bits, as shown below:

        I := 0 ;
        repeat
            I := I - 1 ;
            F := 2 * F ;
            if  ( F >= 1 ) then
                begin
                B[I] = 1 ;
                F := F - 1 ;
                end ; 
            else
                B[I] = 0 ;
        until ( F = 0 ) ;

Note that the preceding Pascal program fragment is presented as a description of the conversion algorithm, not as a computational procedure.

Example:

Convert decimal 0.375 to a binary fraction.

displaymath2700

Binary representation: .011



CS 301 Class Account
Mon Sep 13 11:15:41 ADT 1999