Commodore 2001-8 User Manual page 31

Table of Contents

Advertisement

being calculated in a floating point accumulator. The accuracy is limited to 9 significant digits. Minus
subtracts the value to the right of the minus from the value to the left of the minus sign.
is the BASIC multiply. The value to the right of the multiply is multiplied by the value to the left.
is BASIC's divide. All the numbers to the right of the slash are divided into the expression to the left of
the slash.
t
means exponentiation. All the values to the left of t are raised to power of the value on the right.
Open and close parentheses cause values inside them to be single expressions. All expressions inside
parentheses are evaluated as a single value. Parentheses may be nested and are evaluated outward,
starting from the innermost set of parentheses. In order of precedence, the memory aid "My Dear Aunt
Sally" will help you remember the precedQnce of operators Multiplication first, then Division, Addition,
Subtration. Expressions within parentheses are evaluated first starting from the innermost set of
parentheses. The following set of examples should be tried on your PET to show the operation of the
operators and their precedence.
Addition
?2+2
Subtraction
?4-2
Multiplication
? 6*2
Division
?
12f2
Use of Parenthesis
? 4+8/2
? (4 + 8)12
Order of Operations
?(2+4·(8-4)12P
FUNCTIONS
There are three functions which are available in BASIC which are, at the time of writing, unique to the
PET. The first of these isTT: Whenever this character is used in an expression, BASIC translates it from the
keyboard character ofTI to the value of 3.14159265 etc. It can be used anywhere in any expression and will
always be evaluated as this number. Example: ?ll.
TI$ and the value Tl are two ways to communicate with the real time clock within BASIC. As previously
indicated, every time a screen refresh occurs, (1/6Oth of a second), a value within the PET is updated. This
value is measured as a 24·hour real-time clock. It is available to the programmer in its binary form by the
expression TI, which gives the value the current number that BASIC is keeping. This number is kept as a
three byte binary number whose value is stated in numbers of 60ths of a second, or so called jiffies. To
evaluate the amount of time that a particular operation has taken, TI can be stored in a variable at the
beginning of the sequence and then the difference calculated by subtracting that variable from the TI at
the end. This function is accurate to
1160
of a second.
Tl$ presents and accepts data in the form of hours, minutes,and seconds. When the expression TI$ is
used, it always presents data in string form with two characters for hours, two characters for minutes,
and two characters for seconds. The value of time in the computer is kept in a 24·hour clock. If it is ten
27

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents