Re: Relational Operators on Windows [message #71559] |
Sun, 27 June 2010 06:56 |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
On Jun 26, 2:18 am, Paulo Penteado <pp.pente...@gmail.com> wrote:
>> IDL> a = [3.2, !VALUES.F_NAN, 2]
>> IDL> a = a [ where(a lt 3) ]
>> % Program caused arithmetic error: Floating illegal operand
>> IDL> print, a
>> 2.00000
>
> That is just a floating point exception. It does not keep the where()
> from working, does not interrupt the program, and can be suppressed
> changing !except.
That is all true, but I think one wants to avoid spurious floating
point exception messages (and not suppress them) when possible,
because sometimes a FP exception can indicate a real problem. Since
no FP exception for the above code occurs on Mac or Linux, I thought I
could get away without using FINITE(), but I will now add it to my
code. --Wayne
|
|
|
Re: Relational Operators on Windows [message #71563 is a reply to message #71559] |
Fri, 25 June 2010 23:18  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Jun 25, 10:45 pm, David Fanning <n...@dfanning.com> wrote:
> Yes. :-)
>
> IDL> a = [3.2, !VALUES.F_NAN, 2]
> IDL> a = a [ where(a lt 3) ]
> % Program caused arithmetic error: Floating illegal operand
> IDL> print, a
> 2.00000
That is just a floating point exception. It does not keep the where()
from working, does not interrupt the program, and can be suppressed
changing !except.
|
|
|
Re: Relational Operators on Windows [message #71564 is a reply to message #71563] |
Fri, 25 June 2010 18:45  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
wlandsman writes:
>
> Sometimes as shortcut for explicitly testing for NaN values, I use the
> fact that NaN is never less than, equal to, or more than a numeric
> value. So if I need to get the values less than 3 in the following
> array
>
> a = [3.2, !VALUES.F_NAN, 2]
>
> I simply say
>
> a = a [ where(a lt 3) ]
>
> and the NaN values are excluded along with the values larger than
> 3. This works fine on Linux and Mac OSX. But someone pointed me
> to the IDL help on relational operators which says,
>
> "On the Windows platform, using relational operators with the values
> infinity or NaN (Not a Number) causes an "illegal operand" error."
>
> Unfortunately, neither of us has access to a Windows machine. Does
> one really get an "illegal operand" value on Windows with the above
> code (so that I need to use the FINITE() function)? Thanks, --Wayne
Yes. :-)
IDL> a = [3.2, !VALUES.F_NAN, 2]
IDL> a = a [ where(a lt 3) ]
% Program caused arithmetic error: Floating illegal operand
IDL> print, a
2.00000
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|