Re: about the precedence of operator "^" and "-" ?

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Mar 25 2011 - 08:58:57 MDT

Hi Xin Xie,

Please see our FAQ on this very topic:

http://www.ncl.ucar.edu/FAQ/#core_lang_012

The negation operator does indeed have a higher precedence, and thus:

   -1^2

becomes

  (-1)^2

which is thus

   1

Of course, using parentheses can change the results:

  -(1^2)

will be

  -1

--Mary

On Mar 25, 2011, at 6:59 AM, Xin Xie wrote:

> Hi,
>
> I found the exponent operator precedence lower than minus, which is not common.
> For example
> print(-1^2)
> yields
> 1
> I am not sure if this is a bug. If so, you may fix it. Thanks very much!
>
> Xin Xie (Jason)
> PhD Student
> School of Marine and Atmospheric Sciences
> Stony Brook University
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Mar 25 08:59:02 2011

This archive was generated by hypermail 2.1.8 : Mon Mar 28 2011 - 08:51:50 MDT