Compensating for Excel rounding errors
PS....
On Nov 24, 4:44*pm, I wrote:
In your example, the problemmatic numbers are in A3:B3. *16.1 and 15.6
are stored internally as exactly
16.10000000000000142108547152020037174224853515625 and
15.59999999999999964472863211994990706443786621093 75.
I did not intend to imply that the numbers in A1:B2 are stored
exactly. In fact, they are not. But coincidentally, their difference
is exactly 0.5, even when we put parentheses around the expression,
which side-steps Excel's attempt to ameliorate such numerical
"errors", and even when we do the computation in VBA.
I want to reiterate that is purely by coincidental. The result of B3-
A3 is much more common.
PS: I also notice that I computed A3-B3, not B3-A3 as you did. That
does not make any difference other than the sign of the result.
|