Greg Ewing wrote:
Steven D'Aprano wrote:
it should be obvious in the same way that string concatenation is different from numerical addition:

1 + 2 = 2 + 1
'1' + '2' != '2' + '1'

However, the proposed arithmetic isn't just non-
commutative, it's non-associative, which is a
much rarer and more surprising thing. We do
at least have

  ('1' + '2') + '3' == '1' + ('2' + '3')

But we don't have:
    (1e40 + -1e40) + 1 == 1e40 + (-1e40 + 1)

Non-associativity is what makes for floating point headaches.
To my knowledge, floating point is at least commutative.

--Scott David Daniels
scott.dani...@acm.org

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to