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

Home » Public Forums » archive » Re: Testing for NODATA presence in a dataset
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: Testing for NODATA presence in a dataset [message #33388 is a reply to message #33386] Sat, 21 December 2002 14:20 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jonathan Greenberg (greenberg@ucdavis.edu) writes:

> I'm having a problem testing for whether an entry in an array is NAN --
> doing something like:
>
> If (value EQ !VALUES.F_NAN) then begin
> print,'Not a number'
> Endif else begin
> print,'Is a number!'
> Endelse
>
> Will always return 'Is a number', even if I set:
> value = !VALUES.F_NAN
>
> What's going wrong with this?

The problem is that NAN is ... well, not a number.
Thus, you can't use it in expressions that
require a number. (Think of it as a mathematical
Catch-22, if you like.)

The proper way to write this code is like this:

If Finite(value) EQ 0 then begin
print,'Not a number'
Endif else begin
print,'Is a number!'
Endelse

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Can't get an cell select event
Next Topic: 3d sphere revisited

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

Current Time: Thu Oct 09 06:48:32 PDT 2025

Total time taken to generate the page: 1.03927 seconds