Chapter
51
Basic
Concepts
Normally, logical operators are used in IFiTHEN statements.
For
ex ample
:
IF
A
=
1
OR
C
=
2
THEN PRINT
X
BASIC prints the variable X
if
1
or
both
of
the relational expres-
sions are true. If both are false, BASIC does not print the vari-
able
x.
IF
S$
=
"TEXAS" CIND
C$
=
"AUSTIN" THEN PRINT
Z$
BASIC prints the value
of
Z$
if
S$
contains the word TEXAS
and
C$ contains the word AUSTIN.
You may also use logical operators
to
make bit comparisons
of
2
numeric expressions. In this case, BASIC does a bit-by-bit com-
parison
of
the
2
values, according
to
predefined rules for the spe-
cific operator. Note that the operands are converted
to
integer
type, stored internally as 16-bit, two's complement numbers.
This information
is
important when doing bit comparisons.
Hierarchy
of
Operators
BASIC uses a predefined hierarchy when performing operations
on expressions with multiple operators. This list shows the oper-
ators in the order that BASIC would perform the operations in a
statement. Remember, BASIC evaluates statements from left
to
right. Operators with the same level
of
hierarchy are shown on
the same line.
A
unary
-
*/
\
MOD
+-
<
>
=
<=
>=
<>
NOT
AND
OR, XOR
IMP
Consider this expression:
X
*
X
+
5^2.8
EQV
55