NaN nonsense (was RE: [Python-Dev] Std tests failing, Windows: test_builtin test_charmapcodec test_pow)

Tim Peters
Mon, 8 Jan 2001 03:17:57 -0500

>> (NaN should never compare equal to anything -- not even to itself

[Thomas Wouters]
> You know that's impossible, in Python, right ? (Due to the
> shortcut taken by '==', based on object identity.)

Surely you jest:  I probably knew that while you were still nursing <wink>.

OTOH, Python on WinTel comes remarkably close (by accident):

Python 2.0 (#8, Jan  5 2001, 00:33:19) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> inf = 1e300**2
>>> inf
>>> nan = inf - inf
>>> nan
>>> nan2 = nan * 1.0
>>> nan2
>>> nan == nan2

> Is that going to be 'fixed', too ? :)

Not if I can help it.  I'd be in favor of adding an fcmp function that needs
to be called explicitly when you want the full complexity of 754
comparisons.  Count them all up, and there are 32 distinct 754 binary float
comparison operators!  The 754 std says 26 (from memory, may be 2 more or
less) of those have to be supplied, but-- since 754 is not a language
std --says nothing about how they're to be spelled.

OTOH, C99 resolutely tries to map that into C, and 754 True Believers will
use that as a club.

On the third hand, as Tom MacDonald posted here earlier (he was X3J11
chair), he's not sure anyone will ever implement C99 in whole.  The
complexities of full 754 support are a large part of why he worries about

too-much-too-late-ly y'rs  - tim