|
|
Re: Looking for someone who contacted me a while back. [message #17805 is a reply to message #17797] |
Fri, 05 November 1999 00:00  |
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.
|
|
|
|
|
|
Re: Looking for someone who contacted me a while back. [message #17814 is a reply to message #17797] |
Fri, 05 November 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Todd Bowers (tbowers@nrlssc.navy.mil) writes:
> Oops, I can't remember the name but somebody contacted
> me a few months ago on 3D,4D interpolations. He either does
> or did work for David Fanning Consulting. Told him I'd
> get back in contact with him when I was ready to really
> jump in to the problem. Well... I'm a jumpin'. So please
> contact me if you're you, or if you're not you but are
> interested in accurate 3D+ scatter data stuff.
Dick Jackson, djackson@dfanning.com. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|