I Operators - Commodore VIC-20 Programmer's Reference Manual

Hide thumbs Also See for VIC-20:
Table of Contents

Advertisement

OPERATORS
I
An operator is a special symbol that VIC BASIC recognizes as
representing an operation to be performed on the variables or
constant data. One or more operators, combined with one or more
terms, form an "expression."
VIC BASIC provides arithmetic operators, relational operators,
and Boolean operators.
An arithmetic operator defines an arithmetic operation to be
performed on the adjoining terms. Arithmetic operations are
performed using floating point numbers. Integers are converted to
floating point numbers before an arithmetic operation is performed;
the result is converted back to an integer. Consider the following
operations and their symbols:
a. Addition (+). The plus sign specifies that the term on the left
is to be added to the term on the right. For numeric quantities this is
straightforward addition. Examples:
2 + 2
A+B + C
X%+1
BR+10E-2
The plus sign can be used to add strings; but rather than adding
their values, they are joined together, or concatenated, forming one
longer string. The difference between numeric addition and string
concatenation can be visualized as follows:
Addition numbers:
num1 +num2 = num3
Addition of strings:
I
I
stringi + string2 = string!string2
By concatenation, strings containing up to 255 characters can be
developed.
EXAMPLES:
"FOR" + "WARD"
results in "FORWARD"
"HI" + "THERE"
results in "HITHERE"
A$+B$
results in ASBS
b. Subtraction (-). The minus sign specifies that the term to the
right of the minus sign is to be subtracted from the term to the left.
62
I

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents