Question: In my program, I have a series of if-else statements that look like so:

```
    if ((int)([currentTouch locationInView:self].y/16)<[player y]-1) {
        direction = 1;
    }
    else if ((int)([currentTouch locationInView:self].y/16)>=[player y]-1 && (int)([currentTouch locationInView:self].y/16)<=[player y]+1) {
        direction = 0;
    }
    else if ((int)([currentTouch locationInView:self].y/16)>([player y]+1)) {
        direction = -1;
    }

```

As best I can tell, these should be the only three options, and yet none of them are evaluating to true. I set a breakpoint at runtime and compared the two values, with the first being greater than the second. However, the third else if statement was skipped over as if it were false. I feel as though im missing something painfully obvious. Any ideas?

Answer: 
You are missing some parentheses. I'd rewrite it like this:

```
int y16 = [currentTouch locationInView:self].y / 16.0f;
if (y16 < ([player y]-1)) {
    direction = 1;
}
else if ( (y16 >=([player y]-1)) && (y16 <= ([player y]+1)) ) {
    direction = 0;
}
else if (y16 > ([player y]+1)) {
    direction = -1;
}

```

Or even

```
int y16 = [currentTouch locationInView:self].y / 16.0f;
if (y16 < ([player y]-1)) {
    direction = 1;
}
else if ( (y16 >=([player y]-1)) && (y16 <= ([player y]+1)) ) {
    direction = 0;
}
else {
    direction = -1;
}

```
As others have mentioned, you can make your code a bit easier to maintain if you make the cast once. You can also change your `if...elseif` statements if you know for sure you want those 3 outcomes and only those 3 outcomes.

Something like this...

```
if ( currentY < lowerBound ) {
    direction = 1;
}else if ( currentY > upperBound ) {
    direction = -1;
}else{  //no need to do 'else if' here because it already failed our other 2 conditions
    direction = 0;
}

```

Are you sure that `currentTouch` and `player y` are valid numbers? I haven't touched any iPhone dev in a while so I'm not sure if it would be a concern or not but that's the first thing that came to mind about something slipping through all 3 conditions.