203
When
there are two or
more
operators at the same priority
level,
the
expression
will be
evaluated
from
left to
right.
(The
exponentiation
will be evaluated
from
right
to
l
e ft.)
Note
that
with
A+B-C,
for example, the answer is the same whether the
additi
o n
or
the
subtraction
is
done
first.
When an expression
contains
multipl
e nested
parentheses,
the
innermost
set
is
evaluated
first
and
evaluation
then
proceeds
outward.
Operation
Parentheses
Variables and Pseudovariables
Functions
Exponentiation (,...
),
(ROT)
Unary minus, negative sign (
-
)
Multiplication
and
division
(*, /)
Addition
and
subtraction (
+,
-
)
Relational
operators(<, <=,
=,
<>, >=,
>)
Logical
operators (AND, OR,
NOT,
XOR)
Level
1
2
3
4
5
6
7
8
9
Operators on BASIC mode cf the
SHARP COMPUTER
are evaluated with the
following
priorities from
highest
to
lowest:
OperatorPrtority
Since
the
COMPUTER
must
have
some way
to
decide
between
these options,
it
uses
its rules of operator
priority.
Because
division
has a
higher "priority"
than
addition
(see below), it
will
choose to do the division first and
then
the
addition,
i.e., i
t will
choose the second option and
return a
value
of
65
for
the
expression.
or
5
+
45
100
+
45
=
65
5
=
2
as
either a
calculation
or
as
a part
of
a
program,
the COMPUTER
does
not
know
whether
you
meant:
100
/
5+45
When the
SHARP COMPUTER
is
given
a
complex
expression,
it evaluates
the
parts
of the
expression
in
a
sequence determined
by the
priority of the
individual
parts of
the
expression.
If
you
enter
the
expression:
APPENDIXD
Expression
Evaluation
and Operator Priority