double a = 10.123420834;
double b = 100.123412321;
if (a > b) {
// do something here
}
I am trying to compare the two values, the code above doesn’t seems to work. Any idea?
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.
The code is correct.
Note that your snippet is equivalent to
since Objective C uses
doubleby default unless the number is followed by anf.Also note that
a < b, so theifstatement will always evaluate toFALSE. Hence you may want to doto test this properly.