While working/testing/failing those souped up divide routines, I came across something.
Don't know if it's a bug, or just plain unavoidable...
Code:
mn = -2147483600 'almost max'd out at 31 bits
mx = 2147483600 'almost max'd out at 31 bits
st = 1234567 'step size can vary quite a bit
x var long
For x = mn to mx step st
lcdout $fe , 1 , HEX4 x.word1 , ":" , HEX4 x.word0
Next x
The loop never stops! Ever!
It seems that when the step size is larger than the difference between 2^31 -1 and mx, x will roll over from a positive number to a negative number (high bit set) and the loop will keep running. Conversely, if using a negative step size, x will roll over from a negative number to a positive number and the loop will keep running as before.
Looks to me like it's an unavoidable situation...
Any thoughts?
Bookmarks