Bitwise operators, Bitwise operators -8 – Rockwell Automation FactoryTalk View Machine Edition Users Guide User Manual
Page 486
F
ACTORY
T
ALK
V
IEW
M
ACHINE
E
DITION
U
SER
’
S
G
UIDE
23-8
• •
•
•
•
Any statement that evaluates to a non-zero value is regarded as true. For example, the
statement tag1 is false if the value of tag1 is 0, and true if tag1 has any other value.
The logical operators are:
Bitwise operators
Bitwise operators examine and manipulate individual bits within a value.
Symbols
Operator
Action
Example
(For these examples,
tag1 = 5 and tag2 = 7)
AND, &&
and
Returns a 1 if the
statements to the
right and left of the
operator are both
true.
(tag1 < tag2) AND (tag1 == 5)
Both statements are true;
returns a 1.
OR, ||
or
Returns a 1 if either
the statement to the
left or right of the
operator is true.
(tag1 > tag2) OR (tag1 == 5)
tag1 == 5 is true;
returns a 1.
NOT
negation
Reverses the
logical value of the
statement it
operates on.
NOT (tag1 < tag2)
Although tag1 < tag2 is true,
NOT reverses the logical value;
returns a 0.
The parentheses are essential in the above expressions. They determine the evaluation order of
the operators. For more information, see page 23-10.
These operators are for integers only, not floating-point numbers. Do not use them with tags or
expressions that return floating-point values.
Symbol
Operator
Action (for examples, see page 23-10)
&
And
Compares two integers or tags on a bit-by-bit basis.
Returns an integer with a bit set to 1 if both the
corresponding bits in the original numbers are 1. Otherwise,
the resulting bit is 0.