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

Home » Public Forums » archive » Re: negation operator
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: negation operator [message #49324 is a reply to message #49320] Thu, 13 July 2006 09:17 Go to previous messageGo to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Thu, 13 Jul 2006 06:31:18 -0700, greg michael wrote:

> This is odd...
>
> IDL> print,-100 > -90 < 90
>
> print,-100 > -90 < 90
> ^
> Syntax error.
> IDL> print,-100 > (-90) < 90
> -90
>
> Is there any reason why a negation operator should ever come lower than
> anything else?

You get the same problem with exponentiation, which is 2 steps up in
the operator precedence chain (see
http://www.dfanning.com/misc_tips/precedence.html).

IDL> print, 2.^-2

print, 2.^-2
^
% Syntax error.
IDL> print, 2.^(-2)
0.250000

So it's not that fact that `-' shares precedence with '>', just that
both are left-right associative, so you can't put two adjacent. This
doesn't always hold though... for example, how about `++' (2nd highest
precedence) and '~' (2nd to last precedence):

IDL> a=1
IDL> print,~++a
0

but how about:

IDL> print,~-a

print,~-a
^
% Syntax error.

This *should* work. Negation is priority 5, logical negation is
priority 8, so it should evaluate -a first, and then ~(-a). Not sure
if this should be considered a bug or just a weakness of the
interpreter.

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Mac OS X: Creating PDF figures from within IDL
Next Topic: Re: IDL and Macs. Speed is not only about squared roots

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

Current Time: Sat Oct 11 12:31:55 PDT 2025

Total time taken to generate the page: 1.27540 seconds