Reputation: 1811
I have some code, but the if condition is skipping and not being executed even though when it's true. My code in simple terms is as follows:
for(int i = 13;i<anarray.length;i++)
if(i == 13)
{
for(w = i;w>12;w--)
{
if(anarray[w] > 0) //the program skips this line completely even though the element is greater than 0
{
//do some adding
}
if(anarray[w] < 0)
{
//do some other adding
}
}
}
The following pictures should help:
Debug 1:
Debug 2:
Debug 3:
Debug 4:
Upvotes: 0
Views: 2295
Reputation: 127563
Your problem is from
for(int w= m_RSISSteps - 1; w > m_RSISteps - 1; w--)
you just defined w
to be equal to m_RSISteps - 1
so the <
check evaluates to false
and the for loop never executes. Likely your check needs to be corrected, perhaps you meant to do w >= 0
or use some other variable than m_RSISteps
.
To turn it in to your "simplified example" it is like you did
for(int i = 12;i<anarray.length;i++) //These should be 12 not 13 based off of your images.
if(i == 12)
{
for(w = 12;w>12;w--) //HERE
{
if(anarray[w] > 0) //the program skips this line completely even though the element is greater than 0
{
//do some adding
}
if(anarray[w] < 0)
{
//do some other adding
}
}
}
Upvotes: 2