The
PC-3
implements logical operators
as
"bitwise"
logical
functions
on
16-bit
quantities.
(See
note on relational expressions and
True and False.) In normal operations this
is
not
significant because the simple 1 and 0 (True and False),
which
result
from
a
relational expression,
use
only
a single
bit.
If
you
apply a logical operator
to
a value
other
than 0
or
1,
it
works
on
each
bit
in-
dependently.
For
example,
if
A
is
17 and B
is
22,
(A
or
B)
is
23:
17 in binary
notation
is
10001
22
in binary
notation
is
10110
17 OR 22
is
10111
(1
if
1 in either
number,
otherwise 0)
10111
is
23 in decimal.
If
you
are
a
proficient
programmer, there
are
certain applications where this
type
of
operation can
be
very useful. Beginning pro-
grammers should stick
to
clear, simple True
or
False
relational expressions.
Parentheses and Operator Precedence
When evaluation
complex
expressions the
PC-3
follows
a predefined set
of
priorities
which determine the sequence in which opera-
tors
are
evaluated. This can
be
quite
significant.
5 + 2 *3 could be:
7
21
or
6
11
The exact rules
of
"operator
precedence"
are
given in
Appendix
D.
To
avoid having
to
remember all these rules and
to
make
your
program clearer, always
use
parentheses
to
determine the sequence
of
evaluation. The above example
is
clarified
by
writing
either:
55