Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
for/next/step - did i find a bug?
#1
i don't know if this is a bug, or if i'm defining variable kind wrongly ('j' is not stopping at '0') - thanks in advance! Smile

Code:
border 0:cls
dim i,j as uinteger
for i=0 to 6143 step 3
  poke 16384+0+i,128+16+2
  poke 16384+1+i,64+8+1
  poke 16384+2+i,32+4
  next i
lp01:
for j=16384 to 0 step -32
  print at 0,0;j;" "
  pause 1
  for i=0 to 767
    poke 16384+6144+i,peek(i+j) band 127
    next i
  next j
goto lp01
Reply
#2
This has been discussed many times.
You're defining j variable as Uinteger, so a FOR from 16384 DOWNTO 0 will stop when the j variable passes beyond 0, thus negative. This will never happen, because j is always positive (UInteger), so it overflows from 0 to (65535 - 31) and never stops
Reply
#3
Did you try changing the value type? :roll:
Reply
#4
boriel Wrote:Did you try changing the value type? :roll:
nope, i kept uinteger, because i were only using values from 0 to 65535 - btw, i got that overflow issue you told, and this situation is focusing me on try different aproaches when coding - thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)