Commodore 2001-8 User Manual page 140

Table of Contents

Advertisement

ARITHMETIC OPERATORS
SYMBOL
=
I
,
+
SAMPLE STATEMENT
A= 100
LET Z=2.5
B= -A
130 PRINT Xl3
140 X = R'(B'D)
150 PRINT x/1.3
160.Z=R+T+Q
170J=100-1
PURPOSE/USE
Assigns a value to a variable,
the LET is optional.
Negation. Note that 0 - A is subtracUon,
while -
A
is negation.
Exponentation (equal to X*X·X
in the sample statement). oto
=
1. 0 to any
other power
=
C.AtS, with A negative and
B not an integer gives an Fe error.
Multiplication.
Division.
Addition.
Subtraction.
RELATIONAL OPERATORS
Relational operators can be used as part of any expression.
Relational operator expressions will always have a value of True ( -1) or a value of False (0).
Therefore, (5 = 4) = 0, (5 = 5) = - 1, etc.
The THEN clause of an IF statement is executed whenever the formula after the IF is not equal to O. That
is to say, IF X THEN ...is equivalent to IF X
< >
0 THEN ....
SYMBOL
<>
>
<
<=, =<
>=,=>
SAMPLE STATEMENT
10 IF A = 15 THEN 40
70 IF A < > 0 THEN 5
30 IF B >100 THEN 8
160 IF B<2 THEN 10
180 IF 100<=B+CTHEN 10
190 IF Q> = R TH!;N 50
PURPOSE/USE
Expression Equals Expression.
Expression Does Not Equal Expression.
Expression Greater Than Expression.
Expression Less Than Expression.
Expression Less Than Or Equal To
Expression.
Expression Greater Than Or Equal To
Expression.
BOOLEAN OPERATORS
AND
21F A<5 AND B<2THEN 7
If expression 1 (A<5) AND expression 2
(B <2) are both true, then branch to line 7.
OR
IF A <1 OR B <2 THEN 2
If either expression 1 (A <1) OR expression
2 (B <2) is true, then branch to line 2.
NOT
IF NOT Q3 THEN 4
If expression "NOT 03" is true (because
03 is false), then branch to line 4.
NOT - 1
~
0 (NOT true = false).
AND, OR and NOT can be used for bit manipulation, and for performing boolean operations.
These three operators convert their arguments to sixteen bit, signed two's, complement integers in the
0·2

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents