Precedence of rule operators
- Last Updated: July 9, 2021
- 1 minute read
- Corticon
- Documentation
The precedence of operators affects the grouping and evaluation of
expressions. Expressions with higher-precedence operators are evaluated first. Where
several operators have equal precedence, they are evaluated from left to right. The
following table summarizes Corticon's
operator precedence.
| Operator precedence | Operator | Operator Name | Example |
|---|---|---|---|
| 1 | ( ) | Parenthetic expression | (5.5 / 10) |
| 2 | - | Unary negative | -10 |
| not | Boolean test | not 10 | |
| 3 | * | Arithmetic: Multiplication | 5.5 * 10 |
| / | Arithmetic: Division | 5.5 / 10 | |
| ** | Arithmetic: Exponentiation (Powers and Roots) | 5 ** 2 25 ** 0.5 125 ** (1.0/3.0) |
|
| 4 | + | Arithmetic: Addition | 5.5 + 10 |
| - | Arithmetic: Subtraction | 10.0 – 5.5 | |
| 5 | < | Relational: Less Than | 5.5 < 10 |
| <= | Relational: Less Than Or Equal To | 5.5 <= 5.5 | |
| > | Relational: Greater Than | 10 > 5.5 | |
| >= | Relational: Greater Than Or Equal To | 10 >= 10 | |
| = | Relational: Equal | 5.5=5.5 | |
| <> | Relational: Not Equal | 5.5 <> 10 | |
| 6 | (expression and expression) | Logical: AND | (ent1.dec1 > 5.5 and ent1.dec1 < 10) |
| (expression or expression) | Logical: OR | (ent1.dec1 > 5.5 or ent1.dec1 < 10) |
Note: While expressions within parentheses that
are separated by logical AND / OR operators are valid, the component expressions are not
evaluated individually when testing for completeness, and might cause unintended side
effects during rule execution. Best practice within a Corticon Rulesheet is to represent AND conditions as separate
condition rows and OR conditions as separate rules -- doing so allows you to get the full
benefit of Corticon’s logical
analysis.
Note: It is recommended that you place
arithmetic exponentiation expressions in parentheses.