Operator Precedence

In an expression that contains more than one mathematical calculation, the rule engine operates:
  • First on calculations or the arguments of functions contained in parentheses
  • Second on multiplication and division operations reading left to right in the rule syntax
  • Third on addition and subtraction operations reading left to right in the rule syntax
  • For equal-priority operations, the rule engine works from left to right.

For example, the expression 2 + 3 * 4 is equal to 14; multiplication is higher priority than addition, so the rule editor multiplies 3 times 4 to get 12, then adds 2. But the expression (2 + 3) * 4 is equal to 20; in this case the parenthetical calculation is higher priority than multiplication so the rule engine first adds 2 and 3 to get 5, then multiplies by 4.

This is the precedence order of the operators, from highest (1) to lowest (8):

Precedence Operator Type
1 . (dot) Property access
2 +,,not Unary, Arithmetic, boolean
3 *, /, mod, div Multiplication, division
4 +, Addition, subtraction
5 "" String
6 <, <=, >, >= comparison
7 =, is, <>,*=, /=, +=,= Assignment, declaration, comparison, compound assignment. An equals sign (=) used in the "if" portion of a rule is for comparison. In the "then" portion of the statement, it is an assignment operator.
8 and, or Boolean
Order of Precedence
  • www.fico.com