2 - 21 2 - 21
MELSEC-Q
2 THE BASICS OF AD51H-BASIC
2.10.3 Logical operators
Logical operators perform bitwise operations or Boolean operations.
Logical operators provide the value “True” (other than 0) or “False” (0).
In an expression, logical operations will be performed after arithmetic calculations and
relational calculations.
The results of logical calculations are as follows. Each operator is listed in the order of
highest priority to lowest priority, 1) to 6).
1) NOT; Negation
2) AND; Conjunction
X
NOT X
X
Y
X AND Y
1
0
1
1
1
0
1
1
0
0
0
1
0
0
0
0
3) OR; Disjunction
4) XOR; Inequivalence (exclusive OR)
X
Y
X OR Y
X
Y
X XOR Y
1
1
1
1
1
0
1
0
1
1
0
1
0
1
1
0
1
1
0
0
0
0
0
0
5) IMP; Implication
6) EQV; Equivalence
X
Y
X IMP Y
X
Y
X EQV Y
1
1
1
1
1
1
1
0
0
1
0
0
0
1
1
0
1
0
0
0
1
0
0
1
Like relational operators, two or more relations can be tied together by logical
operators to determine the flow of the program, providing a conclusion of True or
False.
Example
D<200 AND F<4
• • • • •
True when D is less than 200 and F is less than 4.
1>10 OR K<0
• • • • •
True when I is greater than 10 or K is less than 0.
NOT P
• • • • •
True when P is equal to 0.