Operator Precedence


The precedence of an operator determines which operations will be evaluated first. As you know from math, parentheses raise the precedence of part of an equation. An example:
5 * 5 + 5 = 30
Because multiplication has a higher precedence than addition, 5*5 will be performed before 5+5. If we want the addition to be done first, we use parentheses to raise the precedence of part of the expression:
5 * (5 + 5) = 50
In this case, 5+5 was peformed before the multiplication and the result was much different.

One more example. The unary operator '-' (not to be confused with the subtraction) makes a number negative. This operator has higher precedence than multiplication. So in this example,

var1=-5*-10;
the numbers are made negative before they are multiplied.