Smallest Number ZX80

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
User avatar
Paul
Posts: 1517
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Smallest Number ZX80

Post by Paul »

Hi,
I used the search of this forum and couldn't any ZX80 related entries about this. This is not a question, I just wanted to share what I saw.
In theory a 16 bit integer normally has a range from -32768 to 32767. I wanted to test if this is the same on a ZX80. So I tried to enter
10 LET A=-32768 which I cannot as the number is seen to be invalid (Syntaxerrorcursor)
10 LET A=-32767 works fine. Even if you want to enter the smallest possible number in a INPUT statement you cannot. But you can calculate this ;)
Just use -32767-1 8-)
10 LET A=-32767-1 works.
Funny that Sinclair Basic does a test on the size of the number during entry, but doesn't recognize negative numbers ;)
(Used EO to test, not real machine. No difference expected)
In theory, there is no difference between theory and practice. But, in practice, there is.
Moggy
Posts: 3266
Joined: Wed Jun 18, 2008 2:00 pm

Re: Smallest Number ZX80

Post by Moggy »

Hi Paul

Will try this on My 80 and get back to You.

moggy
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Smallest Number ZX80

Post by PokeMon »

Paul wrote: Funny that Sinclair Basic does a test on the size of the number during entry, but doesn't recognize negative numbers ;)
(Used EO to test, not real machine. No difference expected)
This is simply to assymmetric values for plus and minus because of the zero which cuts "one".
In general for signed integers 8 bit is defined = positive range 0 to 127, negative range -1 to -128. For 16 bit 0 to 32767 and -1 to -32768.
I think this is caused by simplifying conversion in ZX80 rom.
I think they simply interprete the value and do a NEG (2's complement) when detecting a minus in front.
But not checked the code for it. ;)
Moggy
Posts: 3266
Joined: Wed Jun 18, 2008 2:00 pm

Re: Smallest Number ZX80

Post by Moggy »

@ Paul same result on real ZX80.


Regards
Moggy
Post Reply