i just can not figure out - too tired.
what is wrong here?Code:i = 0; x = 0; y = 0; bool sL = 0; while( sL ) { while( y >= 0 ) { if( x < bkSz && y < bkSz ); { dS[*i*][*0*] = x; dS[*i*][*1*] = y; i++ } y−−; x++; } y = x; x = 0; if( i >= bkSz * bkSz ) sL = 1; }
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 18 of 18
Thread
-
Last edited by enim; 19th Feb 2014 at 17:02.
-
the outer while loop will never be entered since 0 <> false.
also next time use 'code'-tags if you post code -
Selur,
Do you ever run a bit slower?
I was, definitely, expecting you, but, not too fast!
Last edited by enim; 19th Feb 2014 at 17:05.
-
Um, wouldn't it have been obvious just knowing it doesn't work, and glancing at it? Or is that just me?
Originally Posted by Selur -
i actually think that since the OP is setting sL to false and the while loop is effectively being interpreted as while (false) which is always true, then the program does make it past the outer while condition.
the second loop says while y is greater than or equal to 0 evaluate the rest but then he decrements y outside of the inner while loop, so the next time y gets tested it's less than 0 and thus the inner loop is only being executed once and then the gets evaluated as false every other time. -
Maybe the OP thought the while() test was made after executing the loop. Which is not the case as it's written. If he want the loop to execute before the test he should use a do... while loop:
Code:do { blah... } while( sL );
-
Code:
While (0 <> false)
-
-
Guest34343Guest
-
-
Do you mean 0 == false? Or are you not referring to the Basic operator?
Sometimes it needs someone else to look at the code, even if you know the line where the bug is, you sometimes simply don't the problem since you already looked at code for too long. -
actually the loop is entered, sL is set to 0 and then tested in the while conditional, but the while statement becomes while (false) which is always the case since he set it to false just prior to the loop, so the program proceeds past the outer loop and into the inner loop.
think about it for a while, if the test was while (0), the end result is that it's always zero and thus it always gets executed. -
In the OP's original post nothing inside the outer while loop is ever executed. Zero is the definition of false. So the test condition is always evaluated as false. The OP's original code is equivalent to:
Code:i = 0; x = 0; y = 0; bool sL = 0;
No, it's not executed. Try it. The opposite, while(1), creates an endless loop (in the absence of a break inside the loop).Last edited by jagabo; 3rd Jun 2014 at 08:56.
-
actually the loop is entered, sL is set to 0 and then tested in the while conditional, but the while statement becomes while (false) which is always the case since he set it to false just prior to the loop.
-
Thanks everybody for inputs. In fact, Selur's very quick and very first response was very helpful.
I was too tired b'coz grabbing a beer was out of reach that time.
Lately got too busy on absolutely different things.
-
Um...
Code:while(i < bkSz * bkSz )
or if you need to enter at least once start with 'do'
-Edit-
Code:if ( i >= bkSz * bkSz ) break;
-
Originally Posted by enim
Similar Threads
-
What is loop filter in VLC
By solixxx in forum Newbie / General discussionsReplies: 0Last Post: 16th Sep 2012, 13:52 -
Loop video scene
By Kand in forum EditingReplies: 0Last Post: 7th Aug 2012, 08:37 -
Simple task, not so simple (rip/quicksync)
By Trife in forum Newbie / General discussionsReplies: 10Last Post: 12th Aug 2011, 19:57 -
VLC Loop Video
By pepegot1 in forum Software PlayingReplies: 3Last Post: 19th Oct 2010, 01:32 -
Adding extra material to the end of a simple 1 movie dvd (with simple menu)
By ColinKe in forum Authoring (DVD)Replies: 4Last Post: 24th Jul 2009, 22:38