Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    For loop bug

    Bug Reporting (FUZE 4 Nintendo Switch)
    3
    7
    258
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Chronos
      Chronos last edited by

      Found a strange "for loop" bug when going from i=0 to -1 with a step -1.

      // as expected, prints nothing
      for i=0 to 0 step -1 loop
      	print(i, "\n")
      repeat
      print("Start B\n")
      // very inconsistently, prints both 0 and -1
      for i=0 to -1 step -1 loop
      	print(i, "\n")
      repeat
      
      loop
      update()
      repeat
      

      ID: 56XK7MDN5

      1 Reply Last reply Reply Quote 0
      • joyrider3774
        joyrider3774 last edited by joyrider3774

        i don't think it's a bug as it goes until -1 -1 so actually -2
        it does endvalue -1

        But it is indeed weird with the 1st one. it probably does some calulcations with start value and end value. And having both the same might have an influence. (like it checks if startval and endval are the same if so do nothing) I try to not use for loops with negative steps. If i need it i use a while

        1 Reply Last reply Reply Quote 0
        • Chronos
          Chronos last edited by

          But a similar for loop going from i=0 to 1 prints 0 and not 1.

          print("Start C\n")
          // prints both 0 and 1
          for i=0 to 1 loop
          	print(i, "\n")
          repeat
          
          waldron 1 Reply Last reply Reply Quote 0
          • waldron
            waldron F @Chronos last edited by

            @Chronos it starts on 0 if you had 10 it would be 9

            1 Reply Last reply Reply Quote 0
            • Chronos
              Chronos last edited by

              I know, I'm stating that to demonstrate the inconsistency in the loops' behaviors. The problem loop is from 0 to -1 including -1.

              waldron 1 Reply Last reply Reply Quote 0
              • waldron
                waldron F @Chronos last edited by

                @Chronos oh I see wish I could help

                1 Reply Last reply Reply Quote 0
                • joyrider3774
                  joyrider3774 last edited by joyrider3774

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post