Kilowatt Software's
Classic Rexx Tutorial
Language Level 4.00 (TRL-2)

# Operator precedence

## Order of expression evaluation

When multiple operators appear within an expression, these are processed as follows:

• Operators with equal precedence are processed left to right

• Operators with higher precedence are processed first

• Parenthesized expressions are completely evaluated as a sub-expression that produces a term for use in the outer expression.

If you are uncertain how an expression will be evaluated, you are advised to use parentheses. This is particularly important when the expression exists in logic that is not typically executed -- e.g. in THEN/ELSE clauses, or WHEN/OTHERWISE clauses.

 Expression Result Rationale 2 + 3 * 4 14 * is performed first, then + (2 + 3) * 4 20 the parenthesized expression is evaluated first 2**2**3 64 not 256 -- the ** have equal precedence, hence they are processed left to right

## Precedence

The order of operator precedence is as follows, from highest to lowest.

 Priority Description Operators 8 Prefix operators + - ¬ \ 7 Power operator ** 6 Multiplication and division operators */ % // 5 Addition and subtraction operators + - 4 Concatenation operators (blank) (abuttal) 3 Comparative operators = == ¬= \= <> > < >= <= ¬> << \>> etc. 2 Logical and operator & 1 Logical or and exclusive or operators | &&

Note: the ¬ operator is a logical-not operator that is not available in all implementations. The backslash (\) is now preferred.