EasyManuals Logo

Sinclair ZX81 User Manual

Sinclair ZX81
92 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 #9 background imageLoading...
Page #9 background image
Chapter 4 - The Sinclair ZX81 as a calculator
Turn the computer on. You can now use it as a calculator, along the lines of chapter 2: type
PRINT
, then
whatever it is that you want working out, & then
NEWLINE
. (We shan't usually bother to tell you to type
NEWLINE
.)
As you would hope, the ZX81 can not only add, but also subtract, multiply using a star * instead of the
usual times sign - this is fairly common on computers) & divide (using / instead of ). Try these out.
+, -, * and / are operations
, & the numbers they operate on are their operands.
The computer can also raise one number to the power of another using the operation
**
(Shifted H. Do
not type * - shifted B - twice): type
PRINT
2
**
3 (Remember the
NEWLINE
.)
& you will get the answer 8 (2 raised to the power 3, or 2
3
, or 2 cubed)
The ZX81 will also work out combinations of the operations. For instance.
PRINT
20-2*3
**
2+4/2*3
gives the answer 8. It goes all round the houses to get this, because first it works out all the powers (
**
) in
order from left to right, & then all the multiplications & divisions (* & /), again from left to right, & then the
additions & subtractions (+ & -), yet again from left to right. Thus our example is worked out in the following
stages:
We formalize this by giving each operation a priority
, a number between 1 & 16. The operations with
highest priority are evaluated first, & operations with equal priority are evaluated in order from left to right.
When - is used to negate something, as when you write -1, then it has priority 9. (This is unary
minus, as
opposed to the binary
minus in 3-1: a unary operation has one operand, while a binary operation has two.
Note that on the ZX81 you cannot use + as a unary operation.)
This order is absolutely rigid, but you can circumvent it by using brackets: anything in brackets is
evaluated first & then treated as a single number, so that
PRINT
3*2+2
gives the answer 6+2 = 6, but
**
has priority 10
* and / have priority 8
+ & - have priority 6

Other manuals for Sinclair ZX81

Questions and Answers:

Question and Answer IconNeed help?

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

Sinclair ZX81 Specifications

General IconGeneral
ProcessorZilog Z80A
Processor Speed3.25 MHz
ROM8 KB
InputMembrane keyboard
StorageCassette tape
Power Supply9V DC
Dimensions167 mm x 40 mm x 175 mm
Release Year1981
ManufacturerSinclair Research
Weight350 g
Operating SystemSinclair BASIC
RAM1 KB
PortsTV out, expansion port
DisplayTelevision (RF modulator output)

Related product manuals