Table 3-3. Boolean Truth Table
The AND operation results in a 1 only if both bits
are
1.
1 AND 1 = 1
oAND 1 = 0
1 AND 0 = 0
oAND 0 = 0
The
OR
operation results in a 1 if either bit
is
1.
1
OR
1 = 1
o
OR
1 = 1
1
OR
0 = 1
o
OR
0 = 0
The
NOT
operation logically complements each
bit
NOT
1 = 0
NOT
0 = 1
Bit-Oriented Boolean Operations
We
include below a discussion of binary
digit
(bit) oriented Boolean opera-
tions.
This discussion
is
presented for those
who
are interested
in
the details
of
how
these operations are performed. If vou do not understand
iL
skip
iL
You
are not skipping anything vou must know.
Bitwise Boolean operations are normally performed on unsigned, positive
16-bit
numbers; these numbers range from 0
to
FFFF
hexadecimal. 0
to
188888
octal. or
0 or 65535 decimal. However, the numbers
must
be
input
to
the
PET
in
the range
±32767
decimal. Appendix F contains hexadecimal-PET decimal con-
version tables. If
Vou
are already familiar
with
Boolean operations, vou have prob-
ablv used binary, octal. or hexadecimal notation, because the
bit-by-bit
conver-
sion
is
straightforward.
PET
BASIC accepts onlv decimal numbers. even for these
Boolean operations. Here are some examples
of bitwise Boolean operations:
Operation
1
AND
1
1 AND
-1
15
OR
240
NOT 0
NOT 1
results
in
1
resu Its
in
1
resu Its in 255
results in
-1
results
in
-2
Hexadecimal equivalent
1 AND 1 equals 1
1 AND
FFFF
equals 1
F
OR
FO
equals
FF
NOT 0 equals
FFFF
NOT 1 equals
FFFE
67