lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Dirk Laurie <> writes:

> On Fri, Aug 05, 2011 at 01:12:28PM +0200, Gavin Wraith wrote:
>> The trouble is, addition and multiplication cannot be commutative 
>> ( x + y == y + x) or associative ( x + ( y + z ) == ( x + y ) + z ) 
>> for floating point numbers. 
> We're straying off-topic, but I can't let this pass.  Addition and
> multiplication _are_ commutative.  Granted, if you have three numbers,
> order of addition becomes important, but that is a consequence of 
> non-associativity.  You have three possible answers, depending only 
> on which of the three numbers sits out in the first addition.

IEEE rounding also gives you

(a+b) == ((a+b)-b)+b

if I remember correctly (possibly I am missing a level of (.-b) here).
That's not exactly fabulous, but it is nice to know that there are
limits to error propagation.

David Kastrup