"Tim Peters" <tim.one at comcast.net> writes: [>>> is Ed Loper, >> is me] >>> I'm also disturbed by the fact that cmp() has something different to >>> say about their equality: >>> >>> >>> cmp(float('nan'), float('nan')) >>> 0 > >> Well, yah. cmp() assumes a total ordering. If there just isn't one, >> what can we do? > > If we could recognize it was a NaN, my preference would be to raise an > exception. Well, we could sorta do this, by doing something like if a > b: return 1 if a < b: return -1 if a == b: return 0 raise ValueError, 'can't compare NaNs' which again goes back to depending on the C compiler. > I was told that GNU sort arranges to make NaNs look "less than" all > non-NaN floats, which is a way to make a total ordering -- kinda. Well, it's an answer. Not sure it's a good one. >> I have at no point claimed that I have given Python 2.4 a coherent >> ieee 754 floating point story. > > Ya, but I keep telling people you claim that <wink>. Oh! So it's your fault <wink>. >> If someone (not me!) has the time and energy to do a 'proper job' (and >> I'd expect working out what that means to be the hard part), then you >> have my support and pre-emptive thanks. > > I don't believe it will happen until all the major C compilers support the > (still optional!) 754 gimmicks in C99 -- or Python is rewritten in some > other language that supports them. Before then, we'd need a small army of > people expert in the intersection of their platform C and the 754 standard, And Python's implementation! > to produce piles of #ifdef'ed platform-specific implementation code. > That's doable, but unlikely. T'would be easier in assembly (as would checking for overflow in int multiplication, but that's another story). I could do 'it' in PPC assembly for MacOS X if I knew what 'it' was, but I'm not a hardcore numerics geek, I was just offended by float('nan') == 1 returning True. Cheers, mwh -- Haha! You had a *really* weak argument! <wink> -- Moshe Zadka, comp.lang.python
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4