[issue1979] Make Decimal comparisons with NaN less arbitrary
Mark Dickinson
report at bugs.python.org
Thu Jan 31 11:06:08 CET 2008
Mark Dickinson added the comment:
Yes, I think it's necessary.
Speaking of standards, it's the current behavior which isn't backed by any
standard or rationale other than the historical one involving now-defunct 3-
way comparisons.
The proposed behavior is much closer to that specified by C99 (see sections
7.12.14 and section F.3) and by IEEE 754 and its upcoming revision (see
section 5.11 of the most recent draft, which is linked to from the wikipedia
page for IEEE 754r). Even better from a standards-compliance perspective
would be to have all comparisons except != involving NaNs raise the
InvalidOperation flag.
The current behavior also breaks something fundamental: namely, that x < y
should have the same truth value as y > x. Python even depends on this for
reversing comparison operators, which explains, but in my opinion doesn't
excuse, the following oddity:
>>> 2 < Decimal("NaN")
True
>>> Decimal(2) < Decimal("NaN")
False
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1979>
__________________________________
More information about the Python-bugs-list
mailing list