Operator Precedence

Operator precedence determines the order in which DPL evaluates operators in an expression. Operators with higher precedence are evaluated first. DPL's operator precedence rules are similar to those in Excel and modern programming languages, so in practice things work as you would expect.

The following list shows the precedence of DPL operators. Operators with the higher precedence appear above those with lower precedence. Operators with the same precedence appear on the same line.

+, -, !Unary plus, Negation, Logical NOT
*, /Multiplication, Division
+, -Addition, Subtraction
<, >, <=, >=Less than, Greater than, Less than or equal to, Greater than or equal to
==, !=Equality, Inequality
&&Logical AND
||Logical OR
? :Conditional operator

The operator precedence shown in this table usually means that DPL evaluates expressions in an intuitive manner. For example, it means that

x+y*z - is equivalent to - x+(y*z)

x^y*z - is equivalent to - (x^y)*z

x || y&&z - is equivalent to - x || (y&&z)

!x&&y<=z?z:z+y - is equivalent to - ((!x)&&(y<=z))?z:(z+y)

You can change the order in which DPL evaluates operators in an expression by enclosing part of the expression in parentheses. DPL treats a parenthesized expression as a single operand and evaluates it before using it in any larger expression. For example, DPL will evaluate 3*4+5 as 17, and 3*(4+5) as 27.

Versions: DPL Professional, DPL Enterprise, DPL Portfolio

See Also