float beat = 1/2;
NSLog(@"timeinterval: %f",beat);
“timeinterval” keeps turning up 0
Is there something wrong with my xcode? Or have I just been sitting here too long and missing something obvious?
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.
This is the result of integer division in C (which is what objc is based on). To fix, explicitly use floating point values: