-10^2

Dave Cragg dcragg at lacscentre.co.uk
Wed May 21 18:59:01 EDT 2003


At 4:25 pm -0600 21/5/03, tom farrell wrote:
>Hi Richard et al...
>
>>    You can force a specific order of operator precedence
>
>Yes, I understand. But I shouldn't have to use () if I want 4*2+5 to yield 13.
>
>My apologies if this is off-topic, but I don't think -10^2 is
>ambiguous. Excel gets it wrong. Appleworks gets it right.
>
>Sadly, and based on complete ignorance alone, I assume that even if
>the the authors of, eg, OpenOffice or StarOffice know that Excel
>gets it wrong, they have made their products get it wrong also, for
>the sake of import/export consistency.
>
>What about Revolution?

I saw this topic discussed on the MacInTouch site earlier and there 
was no consensus. I wouldn't expect any here either.

Personally, I don't see the concept of operator precedence  as a 
mathematical issue. It's just a question of convention and language 
design. For exampe, what's the "right" answer to 4/2*2. To me it's 
just as ambiguous as -10^2. So I follow Richard's advice and use the 
parentheses.

Anyway, the Rev docs state that a minus sign when used as a unary 
operator has a higher precedence than ^. When used as a binary 
operator (subtraction) it has lower precedence. The results seem 
consistent with the docs.


Dave



More information about the use-livecode mailing list