I’m trying to write code that detects if an integer is greater than another integer. Is this possible?
Here is what i’ve done so far.
if (NumCorrect >> NumWrong) {
btnCool.title = @"Awww";
}
else {
btnCool.title = @"Cool!";
}
All its doing is going to the else
EDIT:
NSString *numCorrect = [NSString stringWithFormat:@"%d",NumCorrect];
NSString *numWrong = [NSString stringWithFormat:@"%d", NumWrong];
lblWrong.text = numWrong;
lblCorrect.text = numCorrect;
if (NumCorrect > NumWrong) {
btnCool.title = @"Awww";
} else {
btnCool.title = @"Cool!";
}
Use single
>Double
>>is a bit shift operation. You shift every bit in the binary representation of your variable NumCorrect NumWrong amount of bytes to the right. In almost all cases this will return in a number other then 0, which will then treated as afalsevalue and thus the else block is executed.