3 ms·
Apple's Calculator app used to have an odd floating point rounding behavior (I filed a bug report and they fixed it): 14479.14 - 152.36 =
by tzs 16y ago
Apple's Calculator app used to have an odd floating point rounding behavior (I filed a bug report and they fixed it):
14479.14
-
152.36
=
(result is 14326.78)
1143
/
78
=
(result is 14.6538461538461)
14479.14
-
152.36
=
(result is 14326.7799999999884)
Note that the first and third calculations are the same, yet they resulted in different displayed results!
I never understood this bug. I understand floating point, so understand that some numbers are not exactly representable. However, it should at least still be consistent! The same calculation should give the same results every time.
- hxa7241 16y agoI suppose it depends how exact you are in defining 'same calculation' -- two possible causes of inconsistency are: * FP means the rules of algebra do not hold, so if the calculation is done in a different equivalent form, you can get a different result. * With Intel's old FPU unit, if a value is written to memory rather than staying in registers you can get a different result.