Expression Evaluation

Top  Previous  Next

Expressions are evaluated in the standard algebraic order of operations. The precedence of operations is controlled by operator type and placement of parentheses. Each operation produces an (internal) intermediate value used in subsequent operations. Parentheses may be used to group operations within expressions. Expressions are evaluated beginning with the inner-most set of parentheses and working through to the outer-most set.

Precedence levels for expression evaluation, from highest to lowest, and left-to-right within each level, are:

Level 1

( )

Parenthetical Grouping

Level 2


Unary Minus (Negative sign)

Level 3

procedure call

Gets the RETURN value

Level 4



Level 5

* / %

Multiplication, Division, Modulus Division

Level 6

+ -

Addition, Subtraction

Level 7



Level 8

= <>

Logical Comparisons

Level 9


Boolean expressions

Expressions may produce numeric values, string values, or logical values (true/false evaluation). An expression may contain no operators at all; it may be a single variable, constant value, or procedure call which returns a value.