in reply to Confusion on ** operator
Operator precedence is at work:
The '-' operator as a unary operator binds to "2" with the second highest precedence. First comes the ** binary operator, which binds more closely than the unary '-'. Last in your formula comes addition.
It really is spelled out like this:
(-(2**4))+1
Or in other words: Two to the exponent of four equals sixteen, and then made negative. Negative sixteen plus one equals negative fifteen.
perlop is your friend.
It's the same for common algebraic expressions, hand written or in computer form:
This is not a complete list of operators, of course. For a better list, again, take a look at perlop.
Edit: fixed parens to clarify.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Confusion on ** operator
by AnomalousMonk (Archbishop) on Jan 11, 2009 at 08:38 UTC |