Evaluation of Arithmetic Expressions

Parentheses may be used in expressions to specify the order of evaluation. Expressions within parentheses are evaluated first. When parentheses are nested, the innermost set of parentheses is evaluated first, and then successively more inclusive parentheses are evaluated.

When an expression contains no parentheses, the expression evaluates the arithmetic operators in the following hierarchical order:

  1. unary plus and minus
  2. exponentiation
  3. multiplication and division
  4. addition and subtraction

When the sequence of execution is not specified by parentheses and two or more operators exist at the same hierarchical level, the order of evaluation is from left to right.

An arithmetic expression can begin with only a left parenthesis, a plus sign, a minus sign, an identifier, or a literal. It can end only with a right parenthesis, an identifier, or a literal. Each left parenthesis in an expression must have a matching right parenthesis, and each right parenthesis must have a matching left parenthesis. If the first operator is unary, it must be preceded by a left parenthesis if the expression immediately follows an identifier or another arithmetic expression.

Operands in an arithmetic expression may be any format or USAGE.