2 ms·
Floating point can accurately represent more than just integers. That does not mean that they can accurately perform mathematical operations on them. I'd assum
by wayn3 9y ago
Floating point can accurately represent more than just integers. That does not mean that they can accurately perform mathematical operations on them.
I'd assume that division is implemented as multiplying with the reciprocal (because thats faster). If that's correct, then any division by 3 (or any other number that is not of the form 2^i) breaks your cash register.
Because 1/3 represented as a floating point number equals 0.33333333.. and so on but not indefinitely, 3 * 1/3 = 0.99999999.. - which would be equal to 1 if you were using real numbers. But you don't.