[Python-Dev] Not-a-Number

Steven D'Aprano steve at pearwood.info
Fri Apr 29 08:49:49 CEST 2011


Ben Finney wrote:
> Steven D'Aprano <steve at pearwood.info> writes:
> 
>> Robert Kern wrote:
>>> On 4/28/11 8:44 PM, Steven D'Aprano wrote:
>>>> The real question should be, why does Python treat all NANs as
>>>> signalling NANs instead of quiet NANs? I don't believe this helps
>>>> anyone.
>>> Actually, Python treats all NaNs as quiet NaNs and never signalling NaNs.
>> Sorry, did I get that backwards? I thought it was signalling NANs that
>> cause a signal (in Python terms, an exception)?
>>
>> If I do x = 0.0/0 I get an exception instead of a NAN. Hence a
>> signalling NAN.
> 
> Robert has interpreted your “treats all NaNs as signalling NaNs” to mean
> “treats all objects that Python calls a NaN as signalling NaNs”, and is
> pointing out that no, the objects that Python calls “NaN” are all quiet
> NaNs.

I'm sorry for my lack of clarity. I'm referring to functions which 
potentially produce NANs, not the exceptions themselves. A calculation 
which might have produced a (quiet) NAN as the result instead raises an 
exception (which I'm treating as equivalent to a signal).




-- 
Steven



More information about the Python-Dev mailing list