[Python-Dev] Why is nan != nan?

Mark Dickinson dickinsm at gmail.com
Thu Mar 25 15:22:33 CET 2010


On Thu, Mar 25, 2010 at 2:08 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Jesus Cea wrote:
>> But IEEE 754 was created by pretty clever guys and sure they had a
>> reason for define things in the way they are. Probably we are missing
>> something.
>
> Yes, this is where their "implementable in a hardware circuit" focus
> comes in. They were primarily thinking of a floating point
> representation where the 32/64 bits are *it* - you can't have "multiple
> NaNs" because you don't have the bits available to describe them.

I'm not so sure about this:  standard 64-bit binary IEEE 754 doubles
allow for 2**53-2 different nans (2**52-2 signaling nans, 2**52 quiet
nans):  anything with bit pattern (msb to lsb)

x1111111 1111xxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx

is an infinity or a nan, and there are only 2 infinities.

Mark


More information about the Python-Dev mailing list