[Python-ideas] checking for identity before comparing built-in objects
Steven D'Aprano
steve at pearwood.info
Tue Oct 9 09:05:49 CEST 2012
On Mon, Oct 08, 2012 at 11:44:12PM -0700, Guido van Rossum wrote:
> This smells like a bug in the != operator, it seems to fall back to not ==
> which it didn't used to. More later.....
I'm pretty sure the behaviour is correct. When I get home this evening,
I will check my copy of the Standard Apple Numerics manual (one of the
first IEEE 754 compliant systems). In the meantime, I quote from
"What Every Computer Scientist Should Know About Floating-Point
Arithmetic"
"Since comparing a NaN to a number with <, ≤, >, ≥, or = (but not ≠)
always returns false..."
(Admittedly it doesn't specifically state the case of comparing a NAN
with a NAN.)
http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
--
Steven
More information about the Python-ideas
mailing list