comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Looking for someone who contacted me a while back.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Looking for someone who contacted me a while back. [message #17805 is a reply to message #17797] Fri, 05 November 1999 00:00 Go to previous messageGo to previous message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
davidf@dfanning.com (David Fanning) writes:

> Todd Bowers (tbowers@nrlssc.navy.mil) writes:

>> Damn! is there *anything* you don't know, David??

> Uh, yeah, *why* Where(a EQ !Values.F_NAN) doesn't work. :-)

Once you realize that

IDL> Print, Where(a NE a)

does work, then it makes a certain amount of sense that

IDL> Print, Where(a EQ !Values.F_NAN)

doesn't work. Any comparison of an NaN value to another value returns false,
even if that other value is also an NaN value.

Actually, it's wrong to think of NaN as a specific value. Instead it's a
collection of "values" (bit patterns), all of which are interpreted as NaN.
There are, in fact, 16,777,214 different bit patterns which translate into a
single precision NaN value, and 9,007,199,254,740,990 possible double precision
NaN values. Half of these values are displayed by IDL as "-NaN" when printed
to the screen, but that's actually not required by the IEEE floating point
standard.

It would have made a certain amount of sense for RSI to adopt the convention
that the expression "a EQ b" would return true when the comparison was between
two NaN values, regardless of the exact bit pattern. Instead they adopted the
convention that this returns false when either (or both) of the variables are
NaN. It seems counterintuitive, but once you get the hang of it, it's not too
bad. It does have the nice property that, if the variables A and B are arrays,
then "Where(a EQ b)" only returns the indices of valid numbers.

William Thompson

P.S. In case you're interested, a floating point number is considered to be
NaN if the exponent field is all ones, and at least one of the bits in the
mantissa field is also set to one, regardless of the sign bit. If the exponent
field is all ones, and the mantissa field is all zeroes, then the value is plus
or minus infinity, depending on the sign bit. Everything else is a valid
floating point number.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: oplot problem - solved
Next Topic: Center of mass???

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 22:44:12 PDT 2025

Total time taken to generate the page: 1.67881 seconds