[Python-Dev] Why is nan != nan?
Steven D'Aprano
steve at pearwood.info
Thu Mar 25 15:19:09 CET 2010
On Thu, 25 Mar 2010 11:36:28 pm Jesus Cea wrote:
> Infinites are "not equal" for a good reason, for example.
>
> 1/0 and 2/0 are both infinites, but one is "greater" than the other.
> Or (1/0)^(1/0), an infinite infinitelly "bigger".
I think you're mistaken. In Python 3.1:
>>> x = float('inf')
>>> y = float('inf') + 1
>>> x == y
True
>>> x is y
False
In cardinal arithmetic, there are an infinity of different sized
infinities, but in ordinal arithmetic there are only two: +inf
and -inf, corresponding to the infinities on the real number line. (I
hope that I'm not over-simplifying -- it's been more than a decade
since I've needed to care about this.)
But in any case, the IEEE standard doesn't deal with cardinals: it only
uses two signed infinities.
--
Steven D'Aprano
More information about the Python-Dev
mailing list