[Python-Dev] Re: [Python-checkins] python/dist/src/Objects
floatobject.c, 2.132, 2.133
Armin Rigo
arigo at tunes.org
Thu Sep 23 11:45:02 CEST 2004
Hello Tim,
Your float.richcompare patch, trying to map the C semantics at the Python
level, introduces artificial results when comparing NaN's with longs:
>>> float('nan') > 0
False
>>> float('nan') > 0L
True
I am not aware of all the problems and various platforms, but clearly in the
patch 'vsign' by itself doesn't make much sense if 'v' is a NaN.
Wouldn't all compilers and platforms compare NaNs "strangely", for some
detectable definition of "stange"? Something along the lines of:
#define Py_IS_NAN(v) (!Py_IS_INFINITY(v) && \
( ((v) < 0.0 && (v) > 0.0) || \
!((v) < 1.0 || (v) > -1.0) )
Armin
More information about the Python-Dev
mailing list