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

Charles R Harris charlesr.harris at gmail.com
Mon Sep 29 23:36:45 EDT 2008


Hi David,

On Mon, Sep 29, 2008 at 9:07 PM, David Cournapeau <
david at ar.media.kyoto-u.ac.jp> wrote:

> Charles R Harris wrote:
> >
> > Thanks, that was very helpful. I wonder how widespread the less,
> > lessequal, etc. macros are?
>
> If it is C99, count on some platforms (MS in particular) to not do it.
> Also, when doing things in C, beware that some compilers break most
> reasonable expectations about floating points. In particular, x - x
> where x is a NaN or inf will returns 0 with MS compilers with the
> compiler flags currently used in python (/Ox), which breaks almost any
> code out there relying on proper NaN/Inf handling. So if possible,
> special case with isnan/isinf/isfinite
>

Do any of the MS compilers handle these things correctly? I am loath to load
up the code with expensive macros just to deal with bass ackwards compilers.
Especially if I have to special case all the infs also. However, if I can
use ifdefs to compile various versions I could be talked into it. OTOH, we
could just say the results are undefined when non-conforming compilers are
used.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080929/adbf5fa2/attachment.html>


More information about the NumPy-Discussion mailing list