Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
Is there a proper side in an IF statements expression to have the control value tested against another value (I hope I said that right).
Code:
-(void)mostRolledNumMethod{
    for (int i = 1; i <= 100; i++) {
        if (mostRolledNumber[i] < highestRollSoFar) {
            highestRollSoFar = mostRolledNumber[i];
        }
    }

So should the 'mostRolledNumber' be to the right, left or it does not matter?

-Lars
 
Depends what's in the parentheses.

In this case (a>b) is very different from (b>a). :p

In C the if just looks at the return value of the expression and checks if it is zero (a.k.a FALSE) or non-zero (a.k.a. TRUE).

EDIT: Your code as posted will go through the array mostRolledNumber and update highestRollSoFar when it finds one LESS than highestRollSoFar, which may not be what you want since that tends to be a minimum finding routine.

B
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.