Saturday, September 10, 2011

Handling Binary Fractions Conversions

Understanding integer binaries is simple. But how to handle the fractions and their binaries. Here is how it works -


Converting Decimal Fractions to Binary Fractions

There is a simple, step-by-step method for computing the binary expansion on the right-hand side of the point. We will illustrate the method by converting the decimal value .625 to a binary representation..


  1. Step 1: Begin with the decimal fraction and multiply by 2. The whole number part of the result is the first binary digit to the right of the point.
    1. Because .625 x 2 = 1.25, the first binary digit to the right of the point is a 1.
    2. So far, we have .625 = .1??? . . . (base 2) .
  2. Step 2: Next we disregard the whole number part of the previous result (the 1 in this case) and multiply by 2 once again. The whole number part of this new result is the second binary digit to the right of the point. We will continue this process until we get a zero as our decimal part or until we recognize an infinite repeating pattern.
    1. Because .25 x 2 = 0.50, the second binary digit to the right of the point is a 0.
    2. So far, we have .625 = .10?? . . . (base 2) .
  3. Step 3: Disregarding the whole number part of the previous result (this result was .50 so there actually is no whole number part to disregard in this case), we multiply by 2 once again. The whole number part of the result is now the next binary digit to the right of the point.
    1. Because .50 x 2 = 1.00, the third binary digit to the right of the point is a 1.
    2. So now we have .625 = .101?? . . . (base 2) .
  4. Step 4: In fact, we do not need a Step 4. We are finished in Step 3, because we had 0 as the fractional part of our result there.
    1. Hence the representation of .625 = .101 (base 2) .


Converting Binary Fractions to Decimal Fractions

X-n means 1/Xn. So, 2-2 = 1/4 and 2-3 = 1/8.

To convert an expression in base two notation to base ten notation, just do the arithmetic. Here is 100.101 converted from binary representation to decimal representation:
You should double-check our result by expanding the binary representation.



1
0
0
.
1
0
1
1×22
0×21
0×20
.
1×2-1
0×2-2
1×2-3
1×4 +
0×2 +
0×1+
.
1×0.5 +
0×0.25 +
1×0.125
4 +
0 +
0 +
.
0.5 +
0 +
0.125


4
.
625





References

http://programmedlessons.org/AssemblyTutorial/Chapter-29/ass29_5.html
http://cs.furman.edu/digitaldomain/more/ch6/dec_frac_to_bin.htm

No comments:

Post a Comment