And how does one know this without "memorizing the precedence table"?
The precedence of simple arithmatic operators was set so that one can write polynomials without using parentheses. So just consider the right polynomial and it is easy to derive what the precedence rules are:
-x3+5x2-6x+2
-(x3)+(5(x2))-(6x)+2
-$x**3+5*$x**2-6*$x+2
-($x**3)+(5*($x**2))-(6*$x)+2
So, using (( to indicate "binds tighter than" such that the tightest-binding operators are to the left below, the above tells us:
(( * (( + -
** ((
(( -u
(Where -u fits in relative to * nearly doesn't matter, but unary operators tend to bind tighter in general and that holds true here so that the actual precedence is ** (( -u +u (( * / (( + - as can be verified at perlop.)
|