I am trying to generate a random float(or double) number between 0 and ∏ * 2.
All I can find is how to generate a random float number between 0 and 2.. but that leaves out .28 possibilities. (roughly)
can anyone help?
Thanks
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 should do it:
arc4random returns values between 0 and 2^32-1. Dividing by that number gives the range 0..1. Multiply by the range you need (2pi) gives the final range 0..2pi