[Coco] Fun with Floating-Point Numbers
Juan Castro
jccyc1965 at gmail.com
Mon May 5 11:01:27 EDT 2025
If it's large enough, it stays the same. How large, you ask? Try this:
10 A=100000
20 D=1.002937
30 B=A+1
40 C=B-A
50 IF C<>1 THEN END
60 PRINT A
70 A=INT(D*A)
80 GOTO 30
If you're in a CoCo 3, you can add "5 WIDTH 40:CLS" and "55 LOCATE 0,0" for
neatness.
Juan Castro
Enviado do meu Olivetti Programma 101
http://retropolis.com.br
Em seg., 5 de mai. de 2025 às 11:51, John Mark Mobley via Coco <
coco at maltedmedia.com> escreveu:
> All,
>
> What happens when you add one to a large floating-point number.
>
> 10 X=8.58993459E9
> 20 X=X-100
> 30 PRINT X
> 40 X=X+1
> 50 FOR T=1 TO 600:NEXT T
> 60 GOTO 30
>
> There's likely some rounding going on. And it stops counting at the value
> shown in line 10.
>
> John Mark Mobley
>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>
More information about the Coco
mailing list