Why is it that when I run this code in a loop, only whole numbers are printed in the console?
for (int i = 1; i <= 50; i++) {
zombieSpeed[i] = (((arc4random()%40)+2)/7);
NSLog(@"%f", zombieSpeed[i]);
}
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 problem is here
instead of 40, 2, 7 you should use 40.0, 2.0, 7.0
Also make sure that ZombieSpeed is of float type