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>>a = 1e300 * 1e300
a
1.#INF>>b = 1e66666
b
True>>a == b
-1.#IND>>c = a - a
c
-1.#IND>>d = b - b
d
False>>c == d
False>>c == c
True>>b == b
True>>a == a
True>>a is a
True>>b is b
True>>c is c
True>>d is d
Thanks,>>>
--
Pierre Rouleau