Arithmetic Operators

Five binary and two unary arithmetic operators can be used in arithmetic expressions. They are represented by specific characters that must be preceded and followed by a space.
Binary Operator
Meaning
+
Addition
-
Subtraction
*
Multiplication
Division
**
Exponentiation
Unary Operator
Meaning
+
Multiplication by +1
-
Multiplication by -1

Parentheses are used to highlight or modify the order of evaluation of complex expressions. This improves both readability and maintainability.

Left and right parentheses must be paired in an arithmetic expression with the left parenthesis appearing before its corresponding right parenthesis.

Expressions within parentheses are evaluated first and parenthetical pairs can be nested within other pairs. Evaluation proceeds from the least inclusive pairing outward.

When the order of evaluation is not made explicit by parentheses, expressions are evaluated left-to-right following the hierarchy listed below:
  1. Unary operator
  2. Exponentiation
  3. Multiplication and division
  4. Addition and subtraction.

An arithmetic expression may begin only with a left parenthesis, a unary operator, or an operand (that is, an identifier or a literal). It may end only with a right parenthesis or an operand. An arithmetic expression must contain at least one reference to an identifier or a literal.

If the first operator in an arithmetic expression is a unary operator, it must be immediately preceded by a left parenthesis if that arithmetic expression immediately follows an identifier or another arithmetic expression.

Table 1 shows permissible arithmetic symbol pairs. An arithmetic symbol pair is the combination of two such symbols in sequence. In the figure:
Yes
Indicates a permissible pairing.
No
Indicates that the pairing is not permitted.
Table 1. Valid Arithmetic Symbol Pairs
First Symbol Second Symbol
Identifier or Literal * / ** + - Unary + or Unary - ( )
Identifier or Literal No Yes No No Yes
* / ** + - Yes No Yes Yes No
Unary + or Unary - Yes No No Yes No
  ( Yes No Yes Yes No
  ) No Yes No No Yes