On Fri, Oct 5, 2012 at 12:19 AM, MRAB firstname.lastname@example.org wrote:
On 2012-10-04 15:07, Mike Graham wrote:
On Thu, Oct 4, 2012 at 10:02 AM, Mathias Panzenböck email@example.com wrote:
On 10/04/2012 03:53 PM, Steven D'Aprano wrote:
py> NAN == NAN False
Why isn't this True anyway? Is there a PEP that explains this (IMHO odd) behavior?
IEEE 754 specifies this.
Think of it this way:
Calculation A returns NaN for some reason
Calculation B also returns NaN for some reason
Have they really returned the same result? Just because they're both NaN doesn't mean that they're the _same_ NaN...
The only other viable option would be to declare that (NaN==NaN) is NaN - kinda like SQL's NULL and its weird semantics. And that would be *highly* confusing to many situations.