10-29-2016, 04:08 AM
I'm doing my first tests with ZX Basic. I've tried to create a timer and I found the following issue
In example, t1 is declared as float but the variable only stores the integer value, and the final result is wrong. In this case print result is always 0 or 1, ignoring the decimal part
There is something that escapes me or i don't understand?
The same example adapted to Sinclair basic displays and store decimal part correctly.
Thanks in advance
Code:
REM timer test
DIM t1 as float = 0.00
border 0:paper 0:ink 2:cls
while (0=0)
t1 = (65536 * peek 23674 +256 * peek 23673 + peek 23672) /50
pause int(10+25*RND)
t1 = ((65536 * peek 23674 +256 * peek 23673 + peek 23672) /50) -t1 REM t1 ignores decimal part and has been declared as float
print at 0,0;t1 REM result is always 0 or 1
if inkey$="s" then
end
end if
wend
In example, t1 is declared as float but the variable only stores the integer value, and the final result is wrong. In this case print result is always 0 or 1, ignoring the decimal part
There is something that escapes me or i don't understand?
The same example adapted to Sinclair basic displays and store decimal part correctly.
Thanks in advance