On 8/24/07, Timothy Hochberg <tim.hochberg@ieee.org> wrote:
>>>> On 8/24/07, Christopher Barker <Chris.Barker@noaa.gov> wrote:
> [SNIP]
>>> > You can have several different NaN,
> >
> > You can? I thought NaN was defined by IEEE 754 as a particular bit
> > pattern (one for each precision, anyway).
>>> There's more than one way to spell NaN in binary and they tend to mean
> different things IIRC. Signalling NaNs and quiet NaNs and all of that. (Can
> you tell how superficial my knowledge is here, good).
>> However, if you are inserting the NaNs yourself as placeholders, then they
> should all be the same kind and a binary comparison should be fine.
>
To beat this horse a little more:
IEEE 754 NaNs are represented with the exponential field filled with ones
and some non-zero number in the mantissa. A bit-wise example of a IEEE
floating-point standard<http://en.wikipedia.org/wiki/IEEE_floating-point_standard>single
precision NaN: x11111111axxxxxxxxxxxxxxxxxxxxxx. x = undefined. If a
= 1, it is a *quiet NaN*, otherwise it is a *signalling NaN*.
That's from http://en.wikipedia.org/wiki/NaN#NaN_encodings.
So there a bunch of undefined bits that could be set for the private use of
whoever is producing the NaNs for their own purposes. I don't know how often
those bits vary in practice, but in principle it's not safe to rely on NaNs
being bitwise equal.
--
. __
. |-\
.
. tim.hochberg@ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070824/dd08928b/attachment.html