Operator precedence in PocketBuilder expressions

Order of precedence

To ensure predictable results, all operators in a PocketBuilder expression are evaluated in a specific order of precedence. When the operators have the same precedence, PocketBuilder evaluates them left to right.

These are the operators in descending order of precedence:

Table 4-4: Order of precedence of operators

Operator

Purpose

( )

Grouping (see note below on overriding)

+, -

Unary plus and unary minus (indicates positive or negative number)

^

Exponentiation

*, /

Multiplication and division

+, -

Addition and subtraction; string concatenation

=, >, <, <=, >=, <>

Relational operators

NOT

Negation

AND

Logical and

OR

Logical or

How to override

To override the order, enclose expressions in parentheses. This identifies the group and order in which PocketBuilder will evaluate the expressions. When there are nested groups, the groups are evaluated from the inside out.

For example, in the expression (x+(y*(a+b))), a+b is evaluated first. The sum of a and b is then multiplied by y, and this product is added to x.