Specifications

82
6.3.3 Logical Operators
A logical operator combines multiple tests and manipulates Boolean operands, then returns
the results. It is used, for example, to control the program execution flow or test the value of an
INP function bitwise, as shown in the sample below.
IF d<200 AND f<4 THEN ...
WHILE i>10 OR k<0 ...
IF NOT p THEN ...
barcod% = INP(0) AND &h02
Listed below are the four types of logical operators available.
One or more spaces or tab codes should precede and follow the
NOT, AND, OR, and XOR
operators.
In the logical expressions (or operands), the logical operator first carries out the type conver-
sion to integers before performing the logical operation. If the resultant integer value is out of
the range from -32768 to +32767, a run-time error will occur.
If an expression contains logical operators together with arithmetic and relational operators,
the logical operators are given lowest precedence.
[ 1 ] The NOT operator
The NOT operator reverses data bits by evaluating each bit in an expression and setting the
resultant bits according to the truth table below.
Syntax:
NOT expression
Truth Table for NOT
For example, NOT 0 = -1 (true).
The NOT operation for an integer has the returned value of negative 1s complement. The
NOT X, for instant, is equal to (X+1).
Operations Logical Operators Precedence
Negation
NOT
1
Logical multiplication
AND
2
Logical addition
OR
3
Exclusive logical addition
XOR
4
Bit in Expression Resultant Bit
0
1
1
0