Page 24 - Learn to Program - Basic-256
P. 24
Chapter 1: Meeting BASIC-256 – Say Hello. Page 8
1 say 5 / 2
Program 4: Say another Answer
Did the computer say "2.5"?
+
-
*
/
()
The four basic mathematical operations: addition (+), subtraction
(-), division (/), and multiplication(*) work with numbers to
perform calculations. A numeric value is required on both sides of
these operators. You may also use parenthesis to group
operations together.
Examples include: 1 + 1, 5 * 7, 3.14 * 6 + 2, (1 + 2) * 3 and 5 -
5
Concatenation:
Concatenation is the operation that joins two strings together to make a
longer string. If the strings “abcd” and “xyz” and concatenated together the
string “abcdxyz” would be the result. This operation is called concatenation,
or "cat" for short.
BASIC-256 has three different operators that will concatenate strings, but
they perform differently when the expressions are numbers. The ; operator
will convert expressions to strings and always concatenate, the + operator
will numerically add two numbers but concatenate if either are strings, and
the & operator will perform a 'bit-wise and' if both are numbers but will
otherwise concatenate.
© 2019 James M. Reneau (CC BY-NC-SA 3.0 US)

