EasyManuals Logo

Sinclair QL User Manual

Sinclair QL
422 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #65 background imageLoading...
Page #65 background image
•
•
Data
Types.
Variables
and
Identifiers
The value of a floating point variable may be anything
In
the range:
+
10
-"5
to
+ 10'6'5
With
8 Significant figures.
- -
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
,n
exponent form:
(mantissa) E (exponent)
~
(mantissa) x
10
to
the power (exponent)
Integer
variables can have only whole number values
in
the range -32678
to
32768 The
INTEGER
VARIABLES
following are examples of valid Integer variable names which must end
With
%.
LET
count%
=10
LET
six
tally%
=RNO(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
•
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
INTC5.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:
RNO
(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
*
INTC5.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.
The following examples show common uses of the
INT
function.
100
REMark
Rounding
110
INPUT
decimaL
120
PRINT
INTCdecimaL
+
0.5)
In
the example you input a decimal fraction and the output
IS
rounded. Thus
4.7
would
become 5 but
4.3
would become
4.
You
can achieve the same result using an Integer variable and coercion.
Trigonometrical functions
will
be dealt with
in
a later section but other common numeric
functions are given
In
the
list
below
12/84
NUMERIC
FUNCTIONS
49

Other manuals for Sinclair QL

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Sinclair QL and is the answer not in the manual?

Sinclair QL Specifications

General IconGeneral
ProcessorMotorola 68008
Clock Speed7.5 MHz
RAM128 KB (expandable to 640 KB)
ROM48 KB
Operating SystemSinclair QDOS
Release Year1984
StorageMicrodrive tape loop
Graphics256x256 pixels, 8 colors
PortsRS-232, ROM cartridge
SoundBeeper (internal speaker)

Related product manuals