Rules of Precedence for Arithmetic Operators
|Operator||Rule of Precedence|
|Unary + and –||Positive (+) and negative (-) signs are evaluated first, e.g., +2 or -Salary.|
|^||Exponentiation (^) is performed next, e.g., x^y, that is x raised to the power of y.
Note: If x is negative, y must be an integer.
|* and /||Multiplication (*) and division (/) are performed following exponentiation.|
|+ and –||Addition (+) and subtraction (-) are performed last.|
- Operators of equal precedence are evaluated from left to right in the expression.
- Parentheses can be used to explicitly determine the order of evaluation, overriding the order described above. Each pair of parentheses can contain only one arithmetic expression. Use parentheses extensively in arithmetic expressions.