Basic Error

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
Bill H
Posts: 163
Joined: Sat Nov 27, 2010 6:05 pm

Basic Error

Post by Bill H »

I saw this in an old TI99 4/A newsletter where they was tesing a small basic program on multiple machines. The interesting thing is that the program has the same errors on the TS1000 and Commodore 64. Why would that be? Did they share the same floating point routines?

The program in question:

100 FOR N=1 TO 100
110 IF SQR(N) <> INT(SQR(N)) THEN 130
120 PRINT N
130 NEXT N
140 END


And here is a snip of the newsletter detailing the problem and result on each system

Image

Bill H
Moggy
Posts: 3266
Joined: Wed Jun 18, 2008 2:00 pm

Re: Basic Error

Post by Moggy »

Bill H wrote:I saw this in an old TI99 4/A newsletter where they was tesing a small basic program on multiple machines. The interesting thing is that the program has the same errors on the TS1000 and Commodore 64. Why would that be? Did they share the same floating point routines?

The program in question:

100 FOR N=1 TO 100
110 IF SQR(N) <> INT(SQR(N)) THEN 130
120 PRINT N
130 NEXT N
140 END


And here is a snip of the newsletter detailing the problem and result on each system

Image

Bill H
As far as I can recall the "rom bug" only showed up on fractional computations the most famous being sqr .25 the answers to the numbers missed are all integer values,
without refitting som of the bugged roms I have I can't really comment but the program as listed works ok on My second issue roms.
The problem was ironed out by about 82-83 whats the date on the article, Bill, post 83 the problem was sorted or they have used a very early machine?
Bill H
Posts: 163
Joined: Sat Nov 27, 2010 6:05 pm

Re: Basic Error

Post by Bill H »

It was from December 1984

Bill H
Moggy
Posts: 3266
Joined: Wed Jun 18, 2008 2:00 pm

Re: Basic Error

Post by Moggy »

Bill H wrote:It was from December 1984

Bill H
Hmm a c64 and a zeddy with identical flaws but two different processor types different rom authors an ocean of seperation and a common outcome. time to fit the old roms and check this out if only for the exercise.
Watch this space.
Moggy
User avatar
siggi
Posts: 990
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Basic Error

Post by siggi »

My results (using EO 1.0) are:
Printed values: 1 4 9 16 64

Runtime: 24 seconds in FAST mode

So the timing is correct. But the values are different (no error at 9, error at 49 and 81). Maybe they mixed the results?

Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
Bill H
Posts: 163
Joined: Sat Nov 27, 2010 6:05 pm

Re: Basic Error

Post by Bill H »

siggi wrote:My results (using EO 1.0) are:
Printed values: 1 4 9 16 64

Runtime: 24 seconds in FAST mode

So the timing is correct. But the values are different (no error at 9, error at 49 and 81). Maybe they mixed the results?

Siggi
Siggi

That could possibly be true. If they mixed the TRS80 model 1 and the Timex Sinclair 1000 results. As far as I recall Microsoft wrote the original commodore pet basic that the commodore 64 was based on and the trs80 model 1 with the XB (expansion unit) is level 2 basic which was a microsoft product.

Bill H
Moggy
Posts: 3266
Joined: Wed Jun 18, 2008 2:00 pm

Re: Basic Error

Post by Moggy »

Just ran this on an old rom zeddy and got the same answers as siggi yet if You ask for the sqr of these numbers as a direct command either int or not You get correct results ie sqr 9=3 or Int sqr 9=3. So , does the fault lie in the basic interpreter as opposed to the calculator routines? Or Have I got this wrong and it's the numbers not printed that are at fault? Either way direct command entries show what appears to be correct answers so is it a rounding error?

Moggy
Moggy
Posts: 3266
Joined: Wed Jun 18, 2008 2:00 pm

Re: Basic Error

Post by Moggy »

I think this might shed some light on the problem.

Moggy
Attachments
zx maths.rar
(247.51 KiB) Downloaded 288 times
User avatar
siggi
Posts: 990
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Basic Error

Post by siggi »

A test with the Shoulders of Giants rom (sg81) (with better floating-point math routines) with EO gave:

Printed values are:
1 4 9 16 25 36 49 64 81 100
within 13 seconds.

So there are no calculation errors and it works much faster than the original ZX81 rom.

Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
angus
Posts: 142
Joined: Mon Jun 20, 2011 1:28 pm

Re: Basic Error

Post by angus »

It is slightly quicker by about half a second in FAST mode if you use:


IF NOT SQR (N) = INT(SQR(N)) THEN GOTO 130
Post Reply