There's a problem with incrementing certain datatypes... After a while, all the bits flip back around. Say you have an eight bit number:
11111110
that number is 254.
11111110+1=11111111 = 255 base ten
however since we only have eight bits to store our number in...
11111111+1=00000000 = 0
in other words, 255+1=0.
To prevent this, you have to take extra precautions; like this code I made for incrementing Dwords, so (with the analogous case with our eight bit number) 255+1=255 and not 0, and 0-1=0, and not 255.
i1 as dword
i2 as dword
d1 as dword
d2 as dword
i1=967295
i2=4294960000
d1=12000
d2=4294967295
do
if spacekey()
i1=inc2(i1,i1)
i2=inc2(i2,1)
d1=dec2(d1,1)
d2=dec2(d2,967295)
cls
text 0,0,str$(i1)
text 0,16,str$(i2)
text 0,32,str$(d1)
text 0,48,str$(d2)
sync
endif
loop
function dec2(a as dword, b as dword) `a-b
q as dword
ret as dword
ret=0
q=a-b
if difference(a,q)=b then ret=q
endfunction ret
function inc2(a as dword, b as dword) `a+b
q as dword
ret as dword
ret=4294967295
q=a+b
if difference(a,q)=b then ret=q `if q has not rolled over.
endfunction ret
function difference(a as dword, b as dword)
ret as dword
if a>b
ret=a-b
else
ret=b-a
endif
endfunction ret
Useful if you want to...
uh... I'll get back to you on that.