When ESL evaluates an expression that contains arithmetic operators, it does not necessarily proceed from left to right in performing the necessary arithmetic. Instead, it proceeds according to an established precedence of operations. Precedence is the order in which operators are evaluated. The following lists the order of precedence, from highest to lowest:
- (unary minus)
* / mod
+ - (binary; addition and subtraction)
When precedence cannot be used to determine the order of evaluation - that is, when operators have equal precedence - ESL proceeds from left to right.
You can use parentheses to clarify expressions and to override the precedence of operators. Consider the expression:
(A + 7 / D)
In evaluating this expression, ESL first divides 7 by D and then adds the result to A. If, instead, you want the sum of A + 7 to be divided by D, you must specify:
((A + 7) / D)
If an expression contains nested parentheses (parentheses within parentheses), ESL always begins with the operation within the innermost set of parentheses.