To ensure predictable results, operators in InfoMaker expressions are evaluated in a specific order of precedence. When operators have the same precedence, they are evaluated from left to right.
The following table lists the operators in descending order of precedence:
Operator |
Purpose |
---|---|
( ) |
Grouping |
^ |
Exponentiation |
*, / |
Multiplication and division |
+, - |
Addition and subtraction; string concatenation |
IN,LIKE,BETWEEN |
SQL SELECT statement conditions |
=, >, <, <=, >=, <> |
Relational operators |
AND,OR |
Logical and and logical or |
NOT |
Logical negation |
Overriding the precedence order
Since expressions in parentheses are evaluated first, to override the precedence order, enclose expressions in parentheses. You can also use parentheses to clarify the order of evaluation. Within each set of parentheses, precedence order applies.
In the expression x+y*a+b, y is first multiplied by a (because multiplication has a higher precedence than addition). The result of the multiplication is then added to x and this result is then added to b (because the + operators are evaluated left to right).
To force evaluation in a different order, group expressions with parentheses. For example, in the expression x+(y*(a+b)), a+b is evaluated first. The sum a+b is then multiplied by y, and this product is added to x.