[Python-Dev] Why is nan != nan?
Mark Dickinson
dickinsm at gmail.com
Thu Mar 25 16:05:32 CET 2010
On Thu, Mar 25, 2010 at 3:01 PM, Curt Hagenlocher <curt at hagenlocher.org> wrote:
> On Thu, Mar 25, 2010 at 7:54 AM, Mark Dickinson <dickinsm at gmail.com> wrote:
>>
>> Hmm. I take it back. I was being confused by the fact that sqrt(nan)
>> returns a nan with a new identity; but it does apparently preserve
>> the payload. An example:
>
> I played with this some a few months ago, and both the FPU and the C
> libraries I tested will preserve the payload. I imagine Python just
> inherits their behavior.
Pretty much, yes. I think we've also taken care to preserve payloads
in functions that have been added to the math library as well (e.g.,
the gamma function). Not that that's particularly hard: it's just a
matter of making sure to do "if (isnan(x)) return x;" rather than "if
(isnan(x)) return standard_python_nan;". If that's not true, then
there's a minor bug to be corrected.
Mark
More information about the Python-Dev
mailing list