[Python-Dev] Why is nan != nan? (original) (raw)

Antoine Pitrou solipsis at pitrou.net
Thu Mar 25 15:26:05 CET 2010


Le Thu, 25 Mar 2010 07:19:24 -0700, Curt Hagenlocher a écrit :

On Thu, Mar 25, 2010 at 7:08 AM, 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. Wait, what? I haven't been paying much attention, but this is backwards. There are multiple representations of NaN in the IEEE encoding; that's actually part of the problem with saying that NaN = NaN or NaN != NaN. If you want to ignore the "payload" in the NaN, then you're not just comparing bits any more.

This sounds a bit sophistic, if the (Python) user doesn't have access to the payload anyway.

Antoine.



More information about the Python-Dev mailing list