Page 1 of 1

I can´t explain this (math precision)

Posted: Sat May 20, 2023 10:37 pm
by bola_dor
I know that roughly the mathematical precision of the ZX81 starts to lose after 9 digits, one would expect rounding and exponential expressions.
What I can't explain is why the same statement "LET a=-0.999999999999999999999999" gives two different results in this case.
I would expect -1 as rounding, or anything else, what puzzles me is that the result is not consistent.
I tried the same listing on Spectrum BASIC and the result is always 2... why not -1 ?
  • 10 LET A=-0.9999999999999999
    20 PRINT -0.9999999999999999
    30 PRINT A
    40 POKE 16436,255
    50 POKE 16437,255
    60 LET SS=PEEK 16436+256*PEEK 16437
    70 FOR F=1 TO 100
    80 LET A=-0.9999999999999999
    90 NEXT F
    100 LET EU=PEEK 16436+256*PEEK 16437
    110 LET E1=ABS SS-EU
    120 PRINT A;":",E1/50;""""
test.jpg
test.jpg (1.43 KiB) Viewed 4697 times

Re: I can´t explain this (math precision)

Posted: Sun May 21, 2023 12:05 am
by 1024MAK
Which ROM is your machine using?

Using the last and latest Sinclair official ZX81 ROM I get:
Maths - rounding
Maths - rounding
The above was done on an emulator (the excellent one for iOS) using 16K RAM and the 649 ROM.

I also tried on a emulator for a ZX Spectrum 128, but without the timing parts of the program (so only lines 10 to 30, 70 to 90 and line 120.

This printed -1 three times.

Mark

Re: I can´t explain this (math precision)

Posted: Sun May 21, 2023 12:56 am
by bola_dor
1024MAK wrote: Sun May 21, 2023 12:05 am Which ROM is your machine using?

Using the last and latest Sinclair official ZX81 ROM I get:
IMG_6117.jpeg
The above was done on an emulator (the excellent one for iOS) using 16K RAM and the 649 ROM.

I also tried on a emulator for a ZX Spectrum 128, but without the timing parts of the program (so only lines 10 to 30, 70 to 90 and line 120.

This printed -1 three times.

Mark
i used Eighyone v1.29 zx81.version2.rom
and spec48.rom and spec128.rom

Now I tried zx81.version3.rom and results are al 2...
anyway I woul spect -1

Re: I can´t explain this (math precision)

Posted: Sun May 21, 2023 9:29 pm
by XavSnap
Hi bola_dor,

Try to edit the line 80 using shifted 1 and press New/Line without changes.