678 Rockwell Automation Publication 1756-RM003N-EN-P - October 2011
Appendix C Structured Text Programming
Use Bitwise Operators
Bitwise operators manipulate the bits within a value based on two values.
This is an example.
Determine the Order of Execution
The operations you write into an expression are performed in a prescribed order,
not necessarily from left to right.
• Operations of equal order are performed from left to right.
• If an expression contains multiple operators or functions, group the
conditions in parenthesis ( ) . This ensures the correct order of execution and
makes it easier to read the expression.
For Use this operator Optimal data type
Bitwise AND &, AND DINT
Bitwise OR OR DINT
Bitwise exclusive OR XOR DINT
Bitwise complement NOT DINT
Use this format Example
For this situation Write
value1 operator value2 If input1, input2, and result1 are DINT tags and your
specification says: ‘Calculate the bitwise result of input1
and input2. Store the result in result1.’
result1 := input1 AND input2;
Order Operation
1. ( )
2. function (…)
3. **
4. − (negate)
5. NOT
6. *, /, MOD
7. +, - (subtract)
8. <, <=, >, >=
9. =, <>
10. &, AND
11. XOR
12. OR