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 #14 background imageLoading...
Page #14 background image
How would you use
RND
&
INT
to get a random whole number between 1 & 6, to represent the throw of
a die? (Answer:
INT
(
RND
*6) +1.)
5. Test this rule:
Suppose you choose a number between 1 & 872 & type
RAND
& then your number (&
NEWLINE
)
Then the next value of
RND
will be
(75 * (your number + 1) - 1)/65536
6. (For mathematicians only.)
Let p be a [large] prime, & let a be a primitive root modulo p.
Then if b
i
is the residue of a
i
modulo p (1 b
i
< p-1), the sequence
b
i
-1 / p - 1
is a cylindrical sequence of p-1 distinct numbers in the range 0 to 1 (excluding 1). By choosing a suitably,
these can be made to look fairly random.
65537 is a Mersenne prime, 2
16
-1. Use this & Gauss' law of quadratic reciprocity, to show that 75 is a
primitive root modulo 65537.
The ZX81 uses p=65537 & a=75, & stores some b
i
-1 in memory. The function RND involves replacing
b
i
-1 in memory by b
i+1
-1, & yielding the result (b
i+1
-1)/(p-1). RAND n (with 1 n 65535) makes b
i
equal
to n+1.
7.
INT
always rounds down. To round to the nearest integer, add 0.5 first. For instance,
Compare these with the answers you get when you don't add 0.5
8. Try
PRINT PI
,
PI
-3,
PI
-3.1,
PI
-3.14,
PI
-3.141
This shows how accurately the computer stores .
INT (2.9+0.5) = 3
INT (2.4+0.5) = 2
INT (-2.9+0.5) = -3
INT (-2.4+0.5) = -2

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