[Numpy-discussion] What is the sign of nan?
Charles R Harris
Tue Sep 30 07:17:10 CDT 2008
On Tue, Sep 30, 2008 at 5:10 AM, Pete Forman <firstname.lastname@example.org>wrote:
> I've seen no mention in this thread of IEEE Std 754-2008 which was
> published last month. minNum(x, y) and maxNum(x, y) return a
> floating-point number if the other argument is NaN.
> The OP's question is about the sign of NaN. In 754r it can be tested,
> copied, etc. Operations involving NaNs propagate the payload but not
> the sign bit AFAIK.
OK, here is what is looks like to me at the moment given that numpy requires
an IEEE754 machine:
- We need a reliable value for NAN. This is perhaps best done by using a
union and explicitly twiddling the bits depending on the endian choice of
the architecture. For architectures with foobar extended precision we don't
worry about supporting the extended precision. The result can be tested,
perhaps when numpy is loaded. We could possibly get the value from python.
What happens to PPC?
- Max/min follow the IEEE standard. Given a choice of nan/non-nan, return
non-nan. This can be extended to complex numbers where the choice is based
on the real parts unless they are equal or both nans, in which case the
decision is made on the imaginary parts.
- Signbit returns the value of the signbit function, but nonzero values
are set to 1.
- I am unsure of sign. Should it return signed zeros? Should it return
nan for nan or return the sign of the nan? I am inclined towards returning
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion