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

Grant Edwards grant.b.edwards at gmail.com
Wed Feb 13 13:03:25 EST 2019


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!!



More information about the Python-list mailing list