Sinclair QL Beginner's Manual page 59

Hide thumbs Also See for QL:
Table of Contents

Advertisement

The value of a floating point variable may be anything in the range:
-615
± 10
to ± 10
Suppose in the above program sales were, exceptionally only 3p. Change line 110 to:
110 LET sales = 0.03
This system will change this to:
110 LET sales = 3E-2
To interpret this, start with 3 or 3.0 and move the decimal point -2 places, i.e. two places left. This
shows that:
3E-2 is the same as 0.03
After running the program, the average daily sales are:
1.25E-3 which is the same as 0.00125
Numbers with an E are said to be in exponent form:
(mantissa) E (exponent) = (mantissa) x 10 to the power (exponent)
INTEGER VARIABLES
Integer variables can have only whole number values in the range -32678 to 32768. The following are
examples of valid integer variable names which must end with %.
LET count% = 10
LET six_tally% = RND(10)
LET number_3% = 3
The only disadvantage of integer variables, when whole numbers are required, is the slightly
misleading % symbol on the end of the identifier. It has nothing to do with the concept of percentage.
It is just a convenient symbol tagged on to show that the variable is an integer.
NUMERIC FUNCTIONS
Using a function is a bit like making an omelette. You put in an egg which is processed according to
certain rules (the recipe) and get out an omelette. For example the function INT takes any number as
input and outputs the whole number part. Anything which is input to a function is called a parameter or
argument. INT is a function which gives the integer part of an expression. You may write:
PRINT INT(5.6)
and 5 would be the output. We say that 5.6 is the parameter and the function returns the value 5. A
function may have more than one parameter. You have already met:
RND(1 TO 6)
which is a function with two parameters. But functions always return exactly one value. This must be
so because you can put functions into expressions. For example:
PRINT 2 * INT(5.6)
would produce the output 10. It is an important property of functions that you can use them in
expressions. It follows that they must return a single value which is then used in the expression. INT
and RND are system functions: they come with the system, but later you will see how to write your
own.
+615
with 8 significant figures.

Advertisement

Table of Contents
loading

Table of Contents