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

Schachner, Joseph Joseph.Schachner at Teledyne.com
Wed Feb 13 14:36:34 EST 2019


Because all comparisons with NAN return false, that's the spec.  is NAN > 0? False.  Is NAN< 0?   False.  Is NAN == 0?  False.  Is NAN == <anything>? False. So: Is NAN == NAN? False. And one more:  Is NAN < 1.0e18? False

This makes some sense because NAN is Not A Number, so any comparison to a number fails.

--- Joseph S. 
-----Original Message-----
From: ast <none at gmail.com> 
Sent: Wednesday, February 13, 2019 8:21 AM
To: python-list at python.org
Subject: Why float('Nan') == float('Nan') is False

Hello

 >>> float('Nan') == float('Nan')
False

Why ?

Regards




More information about the Python-list mailing list