Why float('Nan') == float('Nan') is False
Avi Gross
avigross at verizon.net
Wed Feb 13 14:00:57 EST 2019
I won't speak for the IEEE but NOT A NUMBER does not tell you what something
IS.
If "Hello, World!" is not a number as in an int or a float and we throw away
the content and simply call it a NaN or something and then we notice that an
object that is a list of fruits is also not a number so we call it a NaN
too, then should they be equal?
A NaN is a bit like a black hole. Anything thrown in disappears and that is
about all we know about it. No two black holes are the same even if they
seem to have the same mass, spin and charge. All they share is that we don't
know what is in them.
When variable "a" is a Nan then it is sort of a pointer to a concept. The
pointer IS itself but the concepts may not be.
-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net at python.org> On
Behalf Of Grant Edwards
Sent: Wednesday, February 13, 2019 1:03 PM
To: python-list at python.org
Subject: Re: Why float('Nan') == float('Nan') is False
On 2019-02-13, ast <none at gmail.com> wrote:
> Hello
>
> >>> float('Nan') == float('Nan')
> False
If you think that's odd, how about this?
>>> n = float('nan')
>>> n
nan
>>> n is n
True
>>> n == n
False
>>>
> Why ?
IEEE says so.
--
Grant Edwards grant.b.edwards Yow! Like I always say
at -- nothing can beat
gmail.com the BRATWURST here in
DUSSELDORF!!
--
https://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list