On Jan 30, 2014, at 21:56, "Stephen J. Turnbull" firstname.lastname@example.org wrote:
Steven D'Aprano writes:
Floats violate several of the fundamental rules of mathematics, e.g. addition is not commutative:
AFAIK it is.
py> 1e19 + (-1e19 + 0.1) == (1e19 + -1e19) + 0.1 False
This is a failure of associativity, not commutativity. Associativity is in many ways a more fundamental property.
Yeah, the only way commutativity can fail with IEEE floats is if you treat nan as a number and have at least two nans, at least one of them quiet.
But associativity failing isn't really fundamental. This example fails as a consequence of the axiom of (additive) identity not holding. (There is a unique "zero", but it's not true that, for all y, x+y=y implies x is that zero.) The overflow example fails because of closure not holding (unless you count inf and nan as numbers, in which case it again fails because zero fails even more badly).
If you just meant that you lose commutativity before associativity in compositions over fields, then yeah, I guess in that sense associativity is more fundamental.