bugGNU Octave - Bugs: bug #59616, nested while cant detect parameter...

 
 

bug #59616: nested while cant detect parameter change

Submitter:  None
Submitted:  Fri 04 Dec 2020 12:15:23 AM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Bill Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 6.1.0
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 04 Dec 2020 01:01:09 AM UTC, comment #1: 

The code is working properly.  You initialize u to the value of 1 and then enter the first while loop.  In the second while loop you print the value of u, but do not change it.  The value of u (1) is printed 16 x 16 x (176/16) = 2,816 times and then the inner while loop completes.

u is then incremented by 16 and the first while loop starts again.  It prints the value of u (17) and then checks the condition for the innerwhile loop.  Because v has not been changed, it is already larger than 176 from the first time through the while loop and so it is never executed.  The outer while loop continues incremented u by 16 for each round.  The last bits of output on my screen are


u = 1
u = 1
u = 1
u = 1
u = 1
u = 1
u = 17
u = 33
u = 49
u = 65
u = 81
u = 97
u = 113
u = 129


Octave is correctly interpreting the code you have written so I'm closing this report.

Rik <rik5>
Group administrator
Fri 04 Dec 2020 12:15:23 AM UTC, original submission:  

I have the following piece of code:

u = 1;
v = 1;
while(u<=144)
  u # works here
  while(v<=176)
    for k = 0 : 15
      for l = 0 : 15
         u
      end
    end
    v = v + 16;
  end
  u = u + 16;
end

The problem is that when I print u inside the for loop I get
u = 1 every time. I run the program in the online compiler but I got the same result.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-12-04 rik5 StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code