qb45advr.hlp (
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
BASIC Logical Operators
◄Expressions and Operators► ◄Logical Operators► ◄Contents► ◄Index►
──────────────────────────────────────────────────────────────────────────────
Logical Operators
Logical operators perform tests on multiple relations, bit manipulations, or
Boolean operations and return a true (nonzero) or false (zero) value to be
used in making a decision.
Examples
IF D < 200 AND F < 4 THEN 80
WHILE I > 10 OR K < 0
.
.
.
WEND
IF NOT P THEN PRINT "Name not found"
The six logical operators in BASIC, listed in order of precedence, are:
Operator Meaning
NOT Logical complement
AND Conjunction
OR Disjunction (inclusive "or")
XOR Exclusive "or"
EQV Equivalence
IMP Implication
Each operator returns results as indicated below. A "T" indicates a true
value and an "F" indicates a false value. Operators are listed in order of
operator precedence.
Values of Value Returned by Logical Operator
X X X X X
NOT AND OR XOR EQV IMP
X Y X Y Y Y Y Y
─────────────────────────────────────────────────
T T F T T F T T
T F F F T T F F
F T T F T T F T
F F T F F F T T
In an expression, logical operations (also known as Boolean operations) are
performed after arithmetic and relational operations. The operands of
logical operators must be in the range -2,147,483,648 to +2,147,483,647.
Operands are converted to integers (or, if necessary, long integers) before
the logical operation is done. (If the operands are not in this range, an
error results.) If the operands are either 0 or -1, logical operators
return 0 or -1 as the result.