On real ZX81 at Yandex Museum I get wrong result and I found that code listed below print 3 instead of 1:
Code: Select all
10 LET R = 1
20 LET A = -1E-13
30 PRINT R + A
40 STOP
Emulators (EightyOne Sinclair Emulator (https://sourceforge.net/projects/eighty ... -emulator/) and JtyOne (http://www.zx81stuff.org.uk/zx81/jtyone.html) print correct result.
Can someone test this on a real ZX-81?
Full code:
Code: Select all
100 LET P=3.141592654
110 LET S=0
120 LET N=100
130 LET I=0
140 GOSUB 190
150 LET I=I+1
160 IF I<N THEN GOTO 140
170 PRINT P*S/N
180 STOP
190 LET X=P*I/N
200 GOSUB 230
210 LET S=S+R
220 RETURN
230 LET R=X
240 LET A=X
250 LET Y=X*X
260 LET K=1
270 LET A=-A*Y/((K+1)*(K+2))
280 LET R=R+A
290 LET K=K+2
300 IF ABS(A)>1E-16 THEN GOTO 270
310 RETURN