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

Mark Dickinson dickinsm at gmail.com
Mon Nov 9 14:08:41 CET 2009


On Mon, Nov 9, 2009 at 10:42 AM, Stefan Krah <stefan-usenet at bytereef.org> wrote:
> I can also give a decimal use case where the current behavior is problematic
> A variable initialized to a signaling NaN should always cause an exception.
>
> But this doesn't:
>
> salary = Decimal("sNaN")
> minimum_wage = 1000
> if (salary == minimum_wage):
>    print "do stuff"
> else:
>    print "do other stuff"

Hmm.  This does look suspicious.  It's possible we should be raising
for signalling nans here.  For most of what I wrote above I was thinking
of quiet nans.

Mark


More information about the Python-Dev mailing list