ConvertingFP

ConvertingFP - pattern. Because .25 x 2 = .50, the second...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Converting Floating-Point Numbers from Decimal to Binary 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. 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. Because .625 x 2 = 1 .25, the first binary digit to the right of the point is a 1 . So far, we have .625 = .1??? . . . (base 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
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: pattern. Because .25 x 2 = .50, the second binary digit to the right of the point is a . So far, we have .625 = .10?? . . . (base 2) . 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. Because .50 x 2 = 1 .00, the third binary digit to the right of the point is a 1 . So now we have .625 = .101?? . . . (base 2) . 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. Hence the representation of .625 = .101 (base 2) ....
View Full Document

This note was uploaded on 11/04/2009 for the course CS 333 taught by Professor Stankovic during the Fall '08 term at UVA.

Ask a homework question - tutors are online