BASIC-80
Language Elements
Table
2-6.
BASIC-SO
Operators
in
Order
of
Precedence
(Cont'd.)
Order
9.
10.
11.
12.
13.
14.
Operator
Logical NOT, used
to
invert a given
argument.
Logical
AND,
used
to
test
if the nth bit
of
X
and the nth bit
of
Yare
both on.
Logical
OR, used to test
if
the nth bit of X or
Y equals
1.
Logical exclusive OR, used
to
test
if
either
the nth bit of X or the nth bit
of
Y =
1,
but not
both.
Logical implication, used to test
if
the nth bit
of
X is on, then the nth bit
of
Y is on.
Logical equivalence, used to
test
if the nth
bit
of X equals
the
nth
bit
of
Y.
Example
NOT-1
=0
1ANDO=O
150RO=15
15XOR7=
8
OFOFOH
IMP
OOFFH=OFFFOH
OFOFH
EQV.OOFFH=OFOOFH
Operators and Precedence of Evaluation
Complex expressions may be formed by combining constants and variables with
arithmetic, logical, relational, and string operators.
BASIC-SO
follows an order of
precedence to insure orderly and predictable evaluation when analyzing complex
ex-
pressions. This order
of
precedence may be overridden
by
parentheses; any elements
within the parentheses are evaluated first. The numeric operators (arithmetic,
logical, and relational) are listed in order
of
precedence
in
Table 2-6.
Arithmetic Operators
There are seven arithmetic operators in
BASIC-SO,
each performing a familiar
arithmetic operation on two numeric expressions. They are evaluated before the
relational or logical operators, and if two operators
of
equal precedence are found
by
BASIC-SO, they are evaluated from left to right. Table
2-6
lists the arithmetic
operators in order
of
precedence. Some examples
of
arithmetic operators are:
A = 8*(C*2.49)
K1=(L+M)
S
RS
= (83*
Et
.S)
Relational Operators
There are six relational operators in
BASIC-SO,
which test relationships between two
expressions and return a
-1
if the premise
is
true, a 0 if it
is
false. You can write in-
structions to direct program execution according to either result. The relational
operators are evaluated after the arithmetic operators, and if two operators with the
same order
of
precedence are given in an expression, they are evaluated left to right.
Table
2-6
lists the relational operators, and some examples are given below:
IF
(A*2.2)<>8*81
THEN
220
IF
INT(A1) = INT(81) THEN
A=B
IF
A>
B THEN
IF
8>(C*
VA#)THEN
340
2-11