[Numpy-discussion] What is the sign of nan?

Robert Kern robert.kern at gmail.com
Tue Sep 30 02:24:08 EDT 2008


On Tue, Sep 30, 2008 at 00:46, Nathan Bell <wnbell at gmail.com> wrote:
> On Tue, Sep 30, 2008 at 1:20 AM, Robert Kern <robert.kern at gmail.com> wrote:
>>
>> F.9.9.2 The fmax functions
>> 1 If just one argument is a NaN, the fmax functions return the other
>> argument (if both arguments are NaNs, the functions return a NaN).
>> 2 The body of the fmax function might be
>> {return (isgreaterequal(x, y) ||
>>  isnan(y)) ? x : y; }
>>
>> If we want to follow C99 semantics rather than our own
>> NaN-always-propagates semantics, then we should do this instead.
>>
>
> +1 for NaN-always-propagates since we have explicit variants for the
> alternative semantics.
>
> Users are more likely to remember that "NaNs always propagate" than
> "as stated in the C99 standard...".

OTOH, Python 2.6 and up will be following to the C99 standard as
closely as possible. I would prefer to keep up with them. It's true
that "as stated in the C99 standard" is more difficult to remember,
but "NaNs always propagate" is probably not going to be consistent
with everything we actually implement, no matter how hard we try.

Regardless of what policy we use, the best thing is to have a
consistent implementation on every platform and a comprehensive test
suite to ensure that. Then, a user doesn't have to remember; they just
try it out in the interpreter and see what it does.

-- 
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



More information about the NumPy-Discussion mailing list