Commodore 2001-8 User Manual page 142

Table of Contents

Advertisement

7)
NOT
8) AND
9)
OR
RULES FOR EVALUATING EXPRESSIONS
Rules for Evaluating Expressions:
1. Operations of higher precedence are performed before operations of lower precedence. This
mea~s
the
multiplications and divisions are performed before additions and 5ubtracions. As an example,
2
+
10/5
equals 4, not 2.4. When operations of equal precedence are found In a formula, the left-hand one
is executed first: 6 - 3
+
5 = 8, not - 2.
2. The order in which operations are performed can always be specified explicitly through the use of
parentheses. For instance, to add 5 to 3 and then divide that by 4, we would use (5
+
3)/4, which eqals 2.
If, instead, we had used 5+3/4, we would get 5.75 as a result (5 plus 314).
The precedence of operators used in evaluating expressions is as follows, in order beginning with the
highest precedence: (Note: Operators listed on the same line have the same precedence).
1) FORMULAS ENCLOSED IN PARENTHESIS ARE ALWAYS EVALUATED FIRST
2) I
EXPONENTATION
3) NEGATION
-X WHERE X MAY BE A FORMULA
4)' I
MULTIPLICATION AND DIVISION
5)
+ -
ADDITION AND SUBTRACTION
6)
RELATIONAL OPERATORS:
~
EQUAL
<>
NOT EQUAL
(equal precedence
<
LESS THAN
for all six).
>
GREATER THAN
<
=
LESS THAN OR EQUAL
>
=
GREATER THAN OR EQUAL
LOGICAL AND BITWISE "NOT" LIKE NEGATION, NOT TAKES ONLY THE FORMULA TO
ITS RIGHT AS AN ARGUMENT
LOGICAL AND BITWISE "AND"
LOGICAL AND BITWISE "OR"
I
0·4

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents