+24 + 3 * -4 ------ +24 + -12 ----------- 12
The first +
is a unary plus,
so it has high precedence and applies only to the 24.
The -
is a unary minus,
so it applies only to the 4.
Next in order of precedence is the *
,
so three times negative four is calculated yielding negative twelve.
Finally the low precedence +
combines the positive twenty four with the negative twelve.
To show exactly what numbers go with each operator, use parentheses. For example
-1 * ( 9 - 2 ) * 3
means do 9 - 2 first. The ( )
groups together what you
want done first.
After doing the subtraction, the ( 9 - 2 ) becomes a 7:
-1 * 7 * 3
Now follow the left-to-right rule for operators of equal precedence:
-1 * 7 * 3 ------ -7 * 3 -------- -21
What is the value of each of the following expressions?