nOWWeaReSiX (these last two names are considered the same, and refer to the same variable)

The following are not allowed to be the names of variables:

pi PI is a keyword
2001 (it begins with a digit)
A new variable (contains the separated keyword NEW)
3 bears (begins with a digit)
M*A*S*H (* is not a letter nor a digit)
Fotherington-Thomas (- is not a letter nor a digit)

Integer variables can only use the letters A to Z (again, case does not matter, so a to z are also acceptable) – as you can see below, for a variable to be treated as integer, a % symbol somewhere in the same expression must precede it.

Scientific notation

Numerical expressions can be represented by a number and exponent. Try the following to prove the point:

PRINT 2.34e0
PRINT 2.34e1
PRINT 2.34e2

and so on up to:

PRINT 2.34e15

You will see that after a while the computer also starts using scientific notation. Similarly, try:

PRINT 2.34e-1
PRINT 2.34e-2

and so on.

PRINT gives only eight significant digits of a number. Try:

PRINT 4294967295,4294967295-429e7

This proves that the computer can hold the digits of 4294967295, even though it is not prepared to display them all at once.

The ZX Spectrum Next, unless integer variables are expressly used (see above), uses floating point arithmetic, which means that it keeps separate the digits of a number (its mantissa) and the position of the point (the exponent). This is not always exact, even for whole numbers.

Type:

PRINT 1e10+1-1e10,1e10-1e10+1

Numbers are held to about nine and a half digits accuracy, so 1e10 is too big to be held exactly right. The inaccuracy (actually about 2) is more than 1, so the numbers 1e10 and 1e10+1 appear to the computer to be equal. For an even more peculiar example, type:

PRINT 5e9+1-5e9

Here the inaccuracy in 5e9 is only about 1, and the 1 to be added on in fact gets rounded up to 2. The numbers 5e9+1 and 5e9+2 appear to the computer to be equal.


ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.