FAQ  •  Register  •  Login

for/next/step - did i find a bug?

<<

nitrofurano

Posts: 135

Joined: Thu Sep 29, 2011 12:44 pm

Location: Porto, Portugal

Post Thu Nov 03, 2011 1:53 pm

for/next/step - did i find a bug?

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! :)

  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
<<

boriel

Site Admin

Posts: 1144

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Thu Nov 03, 2011 2:50 pm

Re: for/next/step - did i find a bug?

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
<<

boriel

Site Admin

Posts: 1144

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Mon Nov 07, 2011 12:31 pm

Re: for/next/step - did i find a bug?

Did you try changing the value type? :roll:
<<

nitrofurano

Posts: 135

Joined: Thu Sep 29, 2011 12:44 pm

Location: Porto, Portugal

Post Mon Nov 07, 2011 5:15 pm

Re: for/next/step - did i find a bug?

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

Return to Help & Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO