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 #49296] Fri, 14 July 2006 08:02 Go to previous message
greg michael is currently offline  greg michael
Messages: 163
Registered: January 2006
Senior Member
Yes, you're right - I'd got used to the quirk with exponents. I've only
just realised, though, that it appears to mean that there's no such
thing as a negative constant in IDL. They're always calculated values.
Maybe that's normal - I don't know.

greg

JD Smith wrote:
> 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: Fri Oct 10 17:55:49 PDT 2025

Total time taken to generate the page: 0.80402 seconds