[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*Subject*: Re: Looking for someone who contacted me a while back.*From*: thompson(at)orpheus.nascom.nasa.gov (William Thompson)*Date*: 5 Nov 1999 22:51:21 GMT*Newsgroups*: comp.lang.idl-pvwave*Organization*: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA*References*: <7vv6lc$9ld$1@ra.nrl.navy.mil> <MPG.128cd03b21272fb8989944@news.frii.com> <7vvahu$c26$1@ra.nrl.navy.mil> <MPG.128ce6d793f101c3989945@news.frii.com>*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:17132

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.

- Prev by Date:
**Re: where() and IEEE NaN** - Next by Date:
**Re: where() and IEEE NaN** - Prev by thread:
**Re: where() and IEEE NaN** - Next by thread:
**Re: Object Widgets** - Index(es):