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

Home » Public Forums » archive » Re: NaN problems
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: NaN problems [message #43582] Thu, 21 April 2005 06:43 Go to next message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
use the finite() function
Re: NaN problems [message #43583 is a reply to message #43582] Thu, 21 April 2005 06:42 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Lopez Pons writes:

> I have a problem detecting NaN values. When I write:
>
> err=findgen(10)-5
> res=err^2.5
> print,res
>
> NaN NaN NaN NaN NaN
> 0.00000 1.00000 5.65685 15.5885 32.0000
>
> Until here everything is OK, but now i want to look for Nan values in my
> result so I write:
>
> print,where(res EQ !values.f_nan)
> -1
>
> I can see the NaN values in res. Why they are not equal to !values.f_nan?

Because, uh, NANs are *not* numbers:

http://www.dfanning.com/math_tips/nans.html

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: NaN problems [message #43726 is a reply to message #43583] Fri, 22 April 2005 19:43 Go to previous message
Y.T. is currently offline  Y.T.
Messages: 25
Registered: December 2004
Junior Member
> http://www.dfanning.com/math_tips/nans.html

Pretty cool page.

;)

I don't have access to IDL on a win-box, but I have a (potentially
stupid) question: On that page of yours where you write

IDL> print, array ne array
0 0 0 0 0

have you tried the converse, i.e.

IDL> print, array eq array

?

I am asking since, while it is true that a NaN is not equal to a NaN it
does not seem to follow (to my wrinkled brain) that a NaN is
necessarily UNequal to a NaN.

In your version you test for the latter, and I'm kinda curious what
would happen if you tried the former...


cordially


Y.T.

--
Remove YourClothes before you email me.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Syntax for R. Franks extproc_define() in IDL 6.1
Next Topic: Is it possible to call IDL in C or C++ language?

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

Current Time: Wed Oct 08 18:40:03 PDT 2025

Total time taken to generate the page: 0.00541 seconds