EasyManua.ls Logo

Commodore CBM - Page 79

Commodore CBM
447 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Boolean Operators
The Soolean operators
AND,
OR, and
NOT
speeify a Soolean logie
operation
ta
be performed
on
two
variables, on adjacent sides of the operator.
1n the case of NOT. only the term to the right
is
considered. Boolean operations
are not performed
until
ail arithmetic and relational operations have been com-
pleted.
Examples:
IF
A=100
AND
B=100
GOTO
10
If both A and B are equal to 100. branch to
statement
10.
IF
X
<y
AND B>
=44
THEN
F=O
If X
is
less than
Y.
and B
is
greater than or equal to 44.
then set F equal to
O.
IF
A=100
OR
B=100
GOTO
20
If either A or B
has
a
va
lue of 100. branch to
statement 20.
IF
X<Y
OR
B>=44
THEN
F=O
F
is
set to 0 if X
is
less than
Y.
or B
is
greater than
43.
IF
A=l
AND
B=2
OR
C=3
GOTO
30
Take the branch if both
A=l
and
B=2;
also take
the branch if C=3.
A single term being tested for
"true"
or
"fa
Ise" can
be
specified by the term
itself.
with
an
implied"
<
>0"
following it.
Any
non-zero value
is
considered true:
a zero value
is
considered false.
Examples:
IF
A
THEN
B=2
IF
A <
>0
TH
EN
B=2
The above
two
statements are equivalent.
IF
NOT B
GOTO
100
Branch if B
is
false.
i.e
..
equal to
zero.
This
is
probably better
written
as:
IF
B=O
GOTO
100
The three Boolean operators can also
be
used to perform logic operations
on
the individual binary digits of
two
adjacent terms (or
just
the term to the right in
the case of
~~OT).
But the terms must
be
in
the integer range. Boolean operations
are defined by groups of statements.
which
taken together constitute a
"truth
ta-
ble." Table 3-3 gives the truth tables for the Boolean operators used by
PET
BASIC.
66

Table of Contents

Other manuals for Commodore CBM

Related product manuals