in reply to strange result for a simple addition ??
Many floating point numbers don't have an exact binary floating point representation. So after a few operations, it's normal to get odd digits a few places to the right.
For example, 1/3 doesn't have an exact decimal representation. If you truncate to 3 digits past the decimal, and subtract 1/3 three times from one, you'd also have an odd value:
1.000 - 0.333 = 0.667 0.667 - 0.333 = 0.334 0.334 - 0.333 = 0.001
--roboticus
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: strange result for a simple addition ??
by GrandFather (Saint) on Aug 25, 2006 at 20:22 UTC | |
by roboticus (Chancellor) on Aug 26, 2006 at 04:21 UTC |