Glossary
What is Operator precedence?
The order an expression is evaluated in: brackets, then negation, then multiply and divide, then add and subtract, then comparisons, then AND, XOR and OR.
Relying on precedence saves brackets but hides mistakes in review. The practical rule for plant code is to bracket every logical grouping, because the reviewer will not open the standard to check.
For example, Pump := Start OR Hold AND NOT Stop; means Start OR (Hold AND NOT Stop), which is usually not what was meant.
Related terms
- Boolean expression
- An expression whose result is TRUE or FALSE, built from comparisons and the operators AND, OR, XOR and NOT.
- Integer division
- Dividing two integers in ST gives an integer and the fraction is dropped, which is a common cause of an unexpected zero.