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

David Cournapeau david@ar.media.kyoto-u.ac...
Tue Sep 30 00:18:42 CDT 2008


David Cournapeau wrote:
>
> when run tells me:
>
> signbit(NAN) = 0
> signbit(-NAN) = -2147483648
> signbit((-1) * NAN) = 0
> signbit(- NAN + NAN) = -2147483648
> signbit(NAN - NAN) = 0
>
> Does not this indicate that signbit(NAN) is undefined ? I guess I am
> afraid that the glibc NAN is just one type of NAN, and is not the
> behavior of any NAN,

Bah, this is gibberish. signbit test for the signbit (duh), nothing
else, so this is always valid, and never raises a FPE_INVALID: glibc
says that copysign is always valid, but I tested with signbit as well,
and it does not seem to be raised either for that macro.

http://www.gnu.org/software/libc/manual/html_node/FP-Bit-Twiddling.html#FP-Bit-Twiddling

Funny how far a bug in median can take us :)

cheers,

David


More information about the Numpy-discussion mailing list