Operator precedence in PowerBuilder expressions

Order of precedence

To ensure predictable results, all operators in a PowerBuilder expression are evaluated in a specific order of precedence. When the operators have the same precedence, PowerBuilder 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 PowerBuilder 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.