Operators
(
i
i
l
i
The BASIC OPERATORS include ARITHMETIC, RELATIONAL and
LOGICAL OPERATORS. The ARITHMETIC operators include the fol
lowing signs:
+
addition
- subtraction
*
multiplication
/
division
t
raising to a power (exponentiation)
On a line containing more than one operator, there is a set order in
which operations always occur. If several operators are used
together, the computer assigns priorities as follows: First, exponen
tiation, then multiplication and division, and last, addition and sub
traction. If two operators have the same priority, then calculations
are performed in order from left to right; If these operations are to
occur in a different order, Commodore 128 BASIC allows giving a
calculation a higher priority by placing parentheses around it. Opera
tions enclosed in parentheses will be calculated before any other
operation. Make sure the equations have the same number of left
and right parentheses, or a SYNTAX ERROR message is posted
when the program is run.
There are also operators for equalities and inequalities, called RELA
TIONAL operators. Arithmetic operators always take priority over
relational operators.
=
is equal to
<
is less than
>
is greater than
< = or = <
is less than or equal to
> = or = >
is greater than or equal to
<> or ><
is not equal to
Finally, there are three LOGICAL operators, with lower priority than
both arithmetic and relational operators:
AND
OR
NOT
These are most often used to join multiple formulas in IF ... THEN
statements. When they are used with arithmetic operators, they are
evaluated last (i.e., after + and -). If the relationship stated in the
337
BASIC 7.0 ENCYCLOPEDIA—Variables and Operators
Need help?
Do you have a question about the 128D and is the answer not in the manual?