NaN comparisons - Call For Anecdotes

Ian Kelly ian.g.kelly at
Thu Jul 17 22:39:42 CEST 2014

On Thu, Jul 17, 2014 at 1:10 PM, Marko Rauhamaa <marko at> wrote:
> Mathematically, there are undefined operations, for a good reason.
> That's because the limits are not unambiguous and that's why 0/0, 0**0,
> 1/0 and inf-inf are undefined.

Well, 0**0 is usually defined as 1, despite the limits being
ambiguous.  Also, 1/0 in IEEE 754 is defined as inf.

> Why 0/0 results in an exception but inf-inf = nan, I don't see a
> justification.

I expect that float division by zero was made to raise an exception
for consistency with integer division by zero, where it might be
considered inappropriate to switch types and return inf or nan.
Granted that nowadays integer division returns a float anyway, but
there is still floor division to think about. Maybe this should have
been fixed in Python 3, but it wasn't.

More information about the Python-list mailing list