Operators
Operators are the calculations and conditions that are used to define the behavior that is provided by a Logic program. Each operator provides a specific calculation or comparison, for example, the > operator means 'greater than' and the < operator means 'less than'. They can be used in an expression that compares values like this:
IF Value1 > 50 THEN
Value2 := 10;
ELSIF Value1 < 50 THEN
Value2 := 5;
END_IF;
In this expression, if Value1 is greater than 50, then Value2 is 10. If Value1 is less than 50, then Value2 is 5.
Each operator has a precedence level. This determines the order in which the operations are evaluated.
The following table shows the available operators and their precedence:
| Operator | Description | Precedence Level |
|---|---|---|
|
( <expression> ) |
Expression inside parentheses ( ) |
1 (Highest) |
|
Function (<expression>) |
Parameter list of a function or function evaluation |
2 |
|
** |
Exponentiation |
3 |
|
- |
Negation |
4 |
|
NOT |
Value with opposite sign |
4 |
|
* |
Multiplication |
5 |
|
/ |
Division |
5 |
|
MOD |
Modulus operation |
5 |
|
+ |
Addition |
6 |
|
- |
Subtraction |
6 |
|
< |
Less than |
7 |
|
> |
Greater than |
7 |
|
<= |
Less than or equal to |
7 |
|
>= |
Greater than or equal to |
7 |
|
= |
Equality |
8 |
|
<> |
Inequality |
8 |
|
AND, & |
Boolean AND |
9 |
|
XOR |
Boolean exclusive OR |
10 |
|
OR |
Boolean OR |
11 (Lowest) |