On 11/7/2015 3:47 AM, Luuk wrote: > I was reading this thread just now..... > > sqlite> select 9.2+7.9+0+4.0+2.6+1.3-25.0, (9.2+7.9)+(0+4.0+2.6+1.3-25.0); > 3.5527136788005e-15|0.0 > > ;) > > > (the reasons are probably explained in the parts of the thread that i > did not read ;)
Among other quirks, floating point operations are not commutative. Let L be a large number, S a small number - sufficiently small that L + S == L (S is lost to rounding error). Then clearly (L + S) - L == 0, (L - L) + S == S. This matters a lot for many computations, where one can choose just the right order of operations to reduce the error, and choosing wrong means errors accumulate and invalidate the result. See also: https://en.wikipedia.org/wiki/Numerical_stability -- Igor Tandetnik