This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients mark.dickinson, skrah, steven.daprano
Date 2012-08-03.13:03:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <501BCC1F.2050007@pearwood.info>
In-reply-to <1343995605.27.0.275832929857.issue15544@psf.upfronthosting.co.za>
Content
On 03/08/12 22:06, Mark Dickinson wrote:
>
>> Decimal('snan').is_nan() just returns true and I am under the impression
>> that IEEE 754 specifies the same.
>
> Sure, but IEEE 754 also specifies that math.sqrt(<signalling nan>) should
> signal.  Since both math.sqrt and math.isnan are going through __float__,
> we can't keep everyone happy here.

Is it necessarily a given that math.isnan *must* go through __float__? If it 
were written in Python, it would be a simple matter of including

if isinstance(x, Decimal) and x.isnan(): return True

before the conversion to float. By I have no idea whether that is practical in 
the math module.

> The question for me is really what __float__ should do.  IEEE 754 doesn't
> help here, since it doesn't cover decimal floating-point<->  binary
> floating-point conversions.

Until such time that floats officially support snans, I think ValueError is 
the right behaviour.
History
Date User Action Args
2012-08-03 13:03:38steven.dapranosetrecipients: + steven.daprano, mark.dickinson, skrah
2012-08-03 13:03:37steven.dapranolinkissue15544 messages
2012-08-03 13:03:36steven.dapranocreate