on floating-point numbers

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Sep 3 20:45:58 EDT 2021


On 3/09/21 8:11 pm, Christian Gollwitzer wrote:
> Unless you have special numbers like NaN or signed zeros etc., a+b=b+a 
> and a*b=b*a holds also for floats.

The only exception I'm aware of is for NaNs, and it's kind of pendantic:
you can't say that x + NaN == NaN + x, but only because NaNs never
compare equal. You still get a NaN either way, so for all practical
purposes it's commutative.

-- 
Greg


More information about the Python-list mailing list