On 4 October 2016 at 21:32, Arek Bulski <[email protected]> wrote:
> I had  a bug where nan floats failed to compare equal because there seems to
> be more than one nan value and comparison seems to be binary based.

"NaN != NaN" is part of the definition of IEEE 754 floats:
https://en.wikipedia.org/wiki/NaN#Floating_point

That's why it returns False even if you compare a specific NaN
instance with itself:

    >>> x = float("nan")
    >>> x == x
    False

If you need a kinda-like-NaN value that provides reflexive equality,
then Python's None singleton is a better fit.

Cheers,
Nick.

-- 
Nick Coghlan   |   [email protected]   |   Brisbane, Australia
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to