Use bitwise operators, Determine the order of execution – Rockwell Automation Logix5000 Controllers Structured Text Programming Manual User Manual
Page 19

Publication 1756-PM007D-EN-P - November 2012
19
Program Structured Text Chapter 1
Use Bitwise Operators
Bitwise operators manipulate the bits within a value based on two values.
For 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
You’d 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