EasyManuals Logo

Sinclair QL Beginner's Guide

Sinclair QL
135 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 #61 background imageLoading...
Page #61 background image
NUMERIC OPERATIONS
SuperBASIC allows the usual mathematical operations. You may notice that they are like functions
with exactly two operands each. It is also conventional in these cases to put an operand on each side
of the symbol. Sometimes the operation is denoted by a familiar symbol such as + or *. Sometimes
the operation is denoted by a keyword like DIV or MOD but there is no real difference. Numeric
operations have an order of priority. For example, the result of:
PRINT 7 + 3*2
is 13 because the multiplication has a higher priority. However:
PRINT (7+3)*2
will output 20, because brackets over-ride the usual priority. As you will see later so many things can
be done with SuperBASIC expressions that a full statement about priority cannot be made at this
stage (see the Concept Reference Guide if you wish) but the operations we now deal with have the
following order of priority:
highest - raising to a power
multiplication and division (including DIV, MOD)
lowest - add and subtract
The symbols + and - are also used with only one operand which simply denotes positive or negative.
Symbols used in this way have the highest priority of all and can only be over-ridden by the use of
brackets.
Finally if two symbols have equal priority the leftmost operation is performed first so that:
PRINT 7-2 + 5
will cause the subtraction before the addition. This might be important if you should ever deal with
very large or very small numbers.
Operation
Symbol
Examples
Results
Note
Add
+
7+6.6
13.6
Subtract
-
7-6.6
0.4
Multiply
*
3*2.1
2.1*(-3)
6.3
-6.3
Divide
/
7/2
-17/5
3.5
-3.4
Do not divide by zero
Raise to power
^
4^1.5
8
Integer divide
DIV
-8 DIV 2
7 DIV 2
-4
3
Integers only
Do not divide by zero
Modulus
MOD
13 MOD 5
21 MOD 7
-17 MOD 8
3
0
7
Modulus returns the remainder part of a division. Any attempt to divide by zero will generate an error
and terminate program execution.
NUMERIC EXPRESSIONS
Strictly speaking, a numeric expression is an expression which evaluates to a number and there are
more possibilities than we need to discuss here. SuperBASIC allows you to do complex things if you
want to but it also allows you to do simple things in simple ways. In this section we concentrate on
those usual straightforward uses of mathematical features.

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