Hi all,
While trying to use simplejson under Python 2.4.3 I have been
investigating the handling of special floating point values and found
that both Python 2.4 and 2.5 return False when comparing a NaN with
itself. Although surprising, I imagine it could also be correct since
NaN is not a number. But is it correct?
Notice the result of comparing c with itself in the following Python
2.5 session (it works the same on Python 2.4.3) under Win32::
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright" , "credits" or "license" for more information.
1.#INF
1.#INF
True
-1.#IND
-1.#IND
False
False
True
True
True
True
True
True
Thanks,
--
Pierre Rouleau
While trying to use simplejson under Python 2.4.3 I have been
investigating the handling of special floating point values and found
that both Python 2.4 and 2.5 return False when comparing a NaN with
itself. Although surprising, I imagine it could also be correct since
NaN is not a number. But is it correct?
Notice the result of comparing c with itself in the following Python
2.5 session (it works the same on Python 2.4.3) under Win32::
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright" , "credits" or "license" for more information.
>>a = 1e300 * 1e300
>>a
>>a
>>b = 1e66666
>>b
>>b
>>a == b
>>c = a - a
>>c
>>c
>>d = b - b
>>d
>>d
>>c == d
>>c == c
>>b == b
>>a == a
>>a is a
>>b is b
>>c is c
>>d is d
>>>
--
Pierre Rouleau
Comment