Operators
Operators allow you to make complex calculations with arithmetic operations within expressions. Operators use operands to act upon. Normally, operators are used in the following order:
Operand1 Operator Operand 2;
For example:
OUT1 := 5;
This example shows the use of the addition operator:
OUT1 := 5 + 5;
Normally, the value of the calculation is assigned to either an output, external reference, or temporary variable. The following operators are supported in DeltaV expressions:
+, -, *, /, AND, OR, NOT, XOR, MOD, !, =,<>, ~=, !=, <, >, <=, >=, **, :=, (,), x?y:z, ~, ^,&, %
The equality operator (=) takes precedence over the AND and OR operators. However, it is important to write your expressions using parenthesis so that the result is as expected.
The expression evaluator is stack oriented and allows a maximum of 32 operands and operators. The use of parentheses to organize the expression minimizes the stack usage. The equations are evaluated using RPN (Reverse Polish Notation).
|
Precedence Order |
Operation |
Symbol |
Order of Evaluation |
|---|---|---|---|
|
1 |
Parenthesis |
(Expression) |
Nonassociative |
|
2 |
Raise to power |
** |
Left |
|
3 |
Logical NOT Bitwise NOT |
! or NOT ~ |
Left |
|
4 |
Multiply Divide Modulus Operator |
* / MOD or % |
Left |
|
5 |
Add Subtract Unary minus |
+ - - |
Left |
|
6 |
Equality test Greater than Less than Greater than or equal to Less than or equal to Does not equal |
= > < >= <= != or <> or ~= |
Left |
|
7 |
Bitwise AND |
& |
Left |
|
8 |
Bitwise Exclusive OR |
^ |
Left |
|
9 |
Bitwise OR |
| |
Left |
|
10 |
Logical AND |
AND |
Left |
|
11 |
Logical Exclusive OR |
XOR |
Left |
|
12 |
Logical OR |
OR |
Left |
|
13 |
Conditional |
?: |
Right |