From 07c8612be653093b0f4e3c212edcb51eacdda7e7 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 19 Jun 2008 12:54:23 +0000 Subject: 25214, tweaked: add warning about exponentiation precedence --- Doc/Zsh/arith.yo | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Doc/Zsh/arith.yo') diff --git a/Doc/Zsh/arith.yo b/Doc/Zsh/arith.yo index 423e6c1bc..dd18ee720 100644 --- a/Doc/Zsh/arith.yo +++ b/Doc/Zsh/arith.yo @@ -93,8 +93,9 @@ cindex(arithmetic operators) cindex(operators, arithmetic) An arithmetic expression uses nearly the same syntax and associativity of expressions as in C. -The following operators are supported (listed in decreasing order -of precedence): + +In the native mode of operation, the following operators are supported +(listed in decreasing order of precedence): startsitem() sitem(tt(PLUS() - ! ~ PLUS()PLUS() --))(unary plus/minus, logical NOT, complement, {pre,post}{in,de}crement) @@ -142,6 +143,11 @@ sitem(tt(= PLUS()= -= *= /= %= &= ^= |= <<= >>= &&= ||= ^^= **=))(assignment) sitem(tt(,))(comma operator) endsitem() +Note the precedence of exponentiation in both cases is below +that of unary operators, hence `tt(-3**2)' evaluates as `tt(9)', not +tt(-9). Use parentheses where necessary: `tt(-(3**2))'. This is +for compatibility with other shells. + cindex(mathematical functions, use of) cindex(functions, math, use of) Mathematical functions can be called with the syntax -- cgit 1.4.1