Going a little nuts here with a super noob issue. How do a check if and int is between two values i.e. want to see if x<100 && x>50 I have tried:
if(x<100 && x>50){
..
}
but not having any joy??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unless your compiler is broken there is nothing wrong with that code. There is probably something wrong with
xAs Sascha stated in the comments make sure that
xis not anNSNumber. The reason for this is ifxis anNSNumberthen the value stored in it is a pointer which value would likely be much higher than 100 (0x4FBC60 for example) and you would want to compare against the-(int)intValue.Other things to consider are comparing against the right data. While implicit number conversions work well you may want to use the same literal comparison as your data type.