Is Python’s == an equivalence relation on the floats?

== is reflexive for all numbers, zero, -zero, ininity, and -infinity, but not for nan. You can get inf, -inf, and nan in native Python just by arithmetic operations on literals, like below. These behave correctly, as in IEEE 754 and without math domain exception: >>> 1e1000 == 1e1000 True >>> 1e1000/1e1000 == 1e1000/1e1000 False … Read more

tech