On 4/29/11 1:35 AM, Nick Coghlan wrote:
On Fri, Apr 29, 2011 at 3:28 PM, Steven D'Aprano
wrote: Robert Kern wrote:
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.
Aside from the divide-by-zero case, we treat NaNs as quiet NaNs.
And in fact, 0.0/0.0 is covered by the more general rule that x/0.0 raises ZeroDivisionError, not a rule that converts IEEE-754 INVALID exceptions into Python exceptions. Other operations that produce a NaN and issue an IEEE-754 INVALID signal do not raise a Python exception. But that's not the difference between signalling NaNs and quiet NaNs. A signalling NaN is one that when it is used as an *input* to an operation, it issues an INVALID signal, not whether a signal is issued when it is the *output* of an operation. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco