[Python-Dev] decimal.py: == and != comparisons involving NaNs

Mark Dickinson dickinsm at gmail.com
Mon Nov 9 14:23:03 CET 2009


On Mon, Nov 9, 2009 at 1:01 PM, Mark Dickinson <dickinsm at gmail.com> wrote:
> current behaviour comes from the IEEE 854 standard;  given the
> absence of helpful information in the Decimal standard, IEEE 854
> is an obvious next place to look.  There's an unofficial copy of the
> standard available at:
>
> http://754r.ucbtest.org/standards/854.pdf
>
> Section 5.7 describes twenty-six(!) distinct comparison operators.

It's interesting to note that out of the 32 possible different comparison
behaviours (two choices of result for each of {equal, lessthan,
greaterthan, unordered}, together with a choice of whether to signal
or not for unordered in each case), the two interesting operators
that are missing from that IEEE 854 table are precisely the ones
that we're discussing:  signalling __eq__ (i.e., return False for
lessthan, greaterthan, unordered, True for equal, and signal on
unordered), and signalling __ne__ (the reverse of the above, but
still signalling on unordered).

(The other four missing operators are the uninteresting ones that
always return True or always return False.)

Mark


More information about the Python-Dev mailing list