Terry Reedy wrote:
On 4/27/2011 2:41 PM, Glenn Linderman wrote:

One issue that I don't fully understand: I know there is only one
instance of None in Python, but I'm not sure where to discover whether
there is only a single, or whether there can be multiple, instances of
NaN or Inf.

I am sure there are multiple instances with just one bit pattern, the same as other floats. Otherwise, float('nan') would have to either randomly or systematically choose from among the possibilities. Ugh.

I think Glenn is asking whether NANs are singletons. They're not:

>>> x = float('nan')
>>> y = float('nan')
>>> x is y
False
>>> [x] == [y]
False


There are functions in the math module that pull apart (and put together) floats.

The IEEE 754 spec is clear that there are multiple bit
sequences that can be used to represent these,

Anyone actually interested in those should use C or possibly the math module float assembly function.

I'd like to point out that way back in the 1980s, Apple's Hypercard allowed users to construct, and compare, distinct NANs without needing to use C or check bit patterns. I think it is painful and ironic that a development system aimed at non-programmers released by a company notorious for "dumbing down" interfaces over 20 years ago had better and simpler support for NANs than we have now.



--
Steven
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to