Look at my simple math script
double s = 3/2;
NSLog (@"%.2f",s);
I get 1, it should be 1.50
How can I fix it?
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.
double s = 3/2means divide the int 3 by the int 2, and then cast the result (which is the int 1) to a double (giving you 1.0).You want this: