4 ms·
(0.3+0.3+0.3) <> 0.9. In fact, 0.9-0.3-0.3-0.3==~1.11e-16 in any IEEE 754 implementation. Now, with proper rounding in the right places, it will all work out.
by beagle3 13y ago
(0.3+0.3+0.3) <> 0.9. In fact, 0.9-0.3-0.3-0.3==~1.11e-16 in any IEEE 754 implementation.
Now, with proper rounding in the right places, it will all work out. However, what rounding and where is much harder than using fixed point.
As long as it's just addition and subtraction, you'll mostly accumulate small errors -- however, once you multiply or compare numbers, all bets are off.
- reikonomusha 13y agoAddition and subtraction can lead to enormous absolute errors. I'm fact, subtraction is one of the biggest culprits for causing instability.
- beagle3 13y agoMostly if followed by multiplication or division. While it is possible to get any magnitude of error with just addition and subtraction, that's usually not the case when just adding and subtracting numbers that are within 8 orders of magnitude, which is usually the range of money (assuming you're using double precision)