(Part 3 of Dr. O’Hara‘s article)
What is the largest integer a ZX81 holds exactly? The manual is wrong in saying that 2³² is the largest. The largest is really 2¹²⁷-2⁹⁵, ie., this 39-digit number: 170141183420855150474555134919112130560. Surprised?
The manual is trying to say that every integer up to and including 2³²–not just 2³²-1–can be held exactly on the ZX81. Moreover, 2³² is the largest integer for which this is true. But every even integer between 2³² and 2³³, every multiple of 4 between 2³³ and 2³⁴, and in general, each multiple of 2ⁿ between 2ⁿ and 2ⁿ⁺³², for n=0, 1, 2,…94 can be held exactly. And every multiple of 2⁹⁵ up to and including 2¹²⁷-2⁹⁵ can be held exactly as well. 2¹²⁷-2⁹⁵ is held as 255,127,255,255,255 and you can’t squeeze another bit into that; the one spare is needed for the sign. Because of overflow and another ZX81 oddity, you may have difficulty in getting this number into Program 1 (SYNTAX Mar.& Apr.82). This works:
2*(2**126-2**95+2**94)
But what of printing? 2³²+2 can be printed exactly: PRINT 2**32+2 (gives 4294967300). Armed with this information, enter: PRINT “42”;2**32+2-42E8 This gives 4294967298, an exact result. But 2⁴⁴ (17592186044416) can’t be printed by this method, as 175921E8 is not divisible by 2¹².
In theory, 2⁴³ could be so printed, but a bit is lost in subtraction on a right shift and is not retrieved. The largest power of 2 for which it works is 2³⁹.
PRINT 2**39 gives 549755810000 and PRINT “5497”;2**39-5497E8 gives the exact result 549755813888. Moral: Don’t believe everything you read in manuals! Things can be better, as well as worse.