Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Yeah, But the PR Fallout ...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Yeah, But the PR Fallout ...
Authored by: paploo on Oct 09, '02 04:50:01PM
Since the number holds more digits of precision during calculations, it turns out that 0.07+0.07 is indeed 0.14, not 0.140000...02. Even if you use the memories, so as to actually be using the 0.0700000...01 values.

Indeed, if you program in floating point very often, you'll find that having those little errors like this are actually normal and *extremely* common. However when operations are done with them, things always work out.

I don't know all the details of the whys and hows, but it has to do with the IEEE way in which floating point numbers are represented. Certain exact values are impossible to exactly represent (or something like that). I know that often times the results of calculations give things like 14.9999999999999 or 15.0000000000001. But I'm unsure of any of the details as to why. I'm just vague on this. (Anyone with exacting knowledge care to follow up on this for me?)

Anyway, it is a tad embarrassing that they didn't write complete algorithms to display it as 0.07 instead of 0.0700000...01, but what users don't know (and can't tell), is that that extra algorithms are written to handle displaying the number the way we want to see it. Internally, the floating point variable is still holding the same value.


(I've written a few calculators in my time. :) )

[ Reply to This | # ]