Array of characters whose name is longer than one letter:

# of
dimensions
+-----------------+-----------------+-------------~ ~-----------------+---------+--------+---------~ ~---------+-------------~ ~-------------+
| 0 1 1 1 1 1 1 1 | 1 1 0 | 0 1 1 ~ ~ 1 | 2 bytes | 1 byte | 2 bytes ~ ~ 2 bytes | 1 byte each ~ ~ |
+-----------------+-----------------+-------------~ ~-----------------+---------+--------+---------~ ~---------+-------------~ ~-------------+
7Fh Letter (≥60h) 2nd Letter Last Letter (≤80h) Total length 1st dimension Last dimension Elements
of elements
and dimensions
+ 1 for # of
dimensions
As you saw in the examples above, numerical values are represented as 5 bytes. These are floating-point values. In contrast to integers which are – as discussed in Chapter 6 and referenced in Chapters 8 through 11 – of a fixed 16 bit (or two-byte) size, floating-point numbers can represent both decimal and integer values. Due to the calculations involved, their usage will slow down your programs; so avoid using them if you do not need decimal points or values higher than 65535.
For floating-point values, any number (except 0) can be written uniquely as: ± m x 2e
where ± is the sign, m is the mantissa, which lies between ½ and 1 (it cannot be 1), and e is a biased exponent.
Suppose you write the fractional m in binary. Because it is a fraction, it will have a binary point (like the decimal point in decimal) and then a binary fraction (like a decimal fraction). So in binary:
| one half | is written as | .1 |
| one quarter | is written as | .01 |
| three quarters | is written as | .11 |
| one tenth | is written as | .000110011001100110011 |
and so on.
With our number m, because it is less than 1, there are no bits before the binary point, and because it is at least ½, the bit immediately after the binary point is a 1. To store the number in the computer, we use five bytes, as follows:
I. write the first eight bits of the mantissa in the second byte (we know that the first bit is 1), the second eight bits in the third byte, the third eight bits in the fourth byte and the fourth eight bits in the fifth byte II. replace the first bit in the second byte which we know is 1 by the sign: 0 for plus, 1 for minus III. write the exponent +128 in the first byte.
For instance, suppose our number is ¹/₁₀:
¹/₁₀ =⁴/₅ x 2⁻³
Thus the mantissa m is .11001100110011001100110011001100 in binary (since the 33rd bit is 1, we shall round the 32nd up from 0 to 1), and the exponent e is -3.
Applying our three rules gives the five bytes: [?]
There is an alternate way of storing whole numbers between -65535 and +65535:
I. the first byte is 0 II. the second byte is 0 for a positive number, FFh for a negative one III. the third and fourth bytes are the less and more significant bytes of the number (or the number +131072 if it is negative), IV. the fifth byte is 0.
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.