These AND & OR are driving me nuts! They are always backwards from what I think.
I have this code in my dice program
I read in a book once that said think of these to operators like this
1) && - You can go to the movies if your room is clean AND dishes are done. Both have to be true to return a true.
2) || - You can go to the movies if your room is clean OR dishes are done. One or the other needs to be true to return a true.
This code works, but I first used the && operator. I scrapped the popUpButton idea and went with another slider to set the min low and max high values of the roll.
It would seem that out of a total max range of 1 to 100. I set the low to 20 and the high to 80 that if the roll was above 80 AND bellow 20 it would re-roll the dice until it was in-range. But && does not work, but the || works fine. I could set min to 49 and max to 50 and I would get one or the other value when I press the roll dice button.
Why, it seems so backwards? This logic is not logical.
I have this code in my dice program
Code:
do {
dieRolls[0] = arc4random() % 100 + 1;
} while ((dieRolls[0] > [numberNoMoreThen intValue]) || (dieRolls[0] < [numberNoLessThen intValue]));
I read in a book once that said think of these to operators like this
1) && - You can go to the movies if your room is clean AND dishes are done. Both have to be true to return a true.
2) || - You can go to the movies if your room is clean OR dishes are done. One or the other needs to be true to return a true.
This code works, but I first used the && operator. I scrapped the popUpButton idea and went with another slider to set the min low and max high values of the roll.
It would seem that out of a total max range of 1 to 100. I set the low to 20 and the high to 80 that if the roll was above 80 AND bellow 20 it would re-roll the dice until it was in-range. But && does not work, but the || works fine. I could set min to 49 and max to 50 and I would get one or the other value when I press the roll dice button.
Why, it seems so backwards? This logic is not logical.