The first ever computer I owned was a Sinclair ZX81, and it was a present along with a 16K memory expansion unit, the computer by itself having only 1K of memory!
The ROM of the ZX81 was only 8K in size, yet included a full floating point BASIC programming language.
The manual was amazing, as it not only got you up and running with connecting the thing, but also explained the built-in version of the BASIC programming language, then taking a brief look at alternative methods of counting (binary and hexadecimal), a very brief look at the hardware, a somewhat thorough description of how the ZX BASIC used memory, an overview of the “system variables”, and a listing of the distinctly non-standard character set which ALSO happened to be in a table with the majority of the Z80 op-codes.
So where does the “NOT PI” of this post title come into it?
In memory ZX BASIC was heavily token based, so PRINT was one byte for example, as was GOTO, and PEEK, and POKE, and every other BASIC keyword. The language also had PI to refer to the infamous mathematical constant.
For speed reasons (!) numeric constants were not only held in textual form, but ALSO in a pre-parsed floating point form, so in memory the value ‘zero’ in BASIC was stored as the character for zero, then a byte to inform the interpreter a floating point constant was to follow, then five more bytes for the floating point constant itself (thus 40-bit accuracy), making a whopping 7 bytes!
In comparison NOT PI was two bytes. NOT was a logical operator, and feeding it a non-zero value (e.g. PI) produced zero. The BASIC interpreter actually had to do the math though, so ran slower. Even so as people wrote larger and larger BASIC programs these sorts of tricks became more common. PI was a very useful single byte value as you could also SGN PI to produce one (PI being positive so the “sign” was positive one) and INT PI to produce three (PI rounded down to an integer).
When Sinclair released the ZX Spectrum the ROM was expanded to 16K, and the character set made somewhat more standard, but much of the BASIC interpreter was unchanged, so all these tricks still worked.
1 PRINT “NO FLOATS”
2 GOTO SGN PI
🙂