[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why float('Nan') == float('Nan') is False

ast <none at gmail.com> writes:

> Hello
>>>> float('Nan') == float('Nan')
> False
> Why ?
> Regards

Others have given the real answer -- IEEE says so, and the people who
wrote the standard are smarter than me.  All the same, this is my take
on the reason for it:  NaN is specifically a representation for "this
has no value".  The == operator compares the values of its operands;
something that has no value can't == anything, including itself.