I’m guessing that most built in random generators return something like this:
[0.0, 1.0)
so if I would like a 50% chance would I use something like this:
if random() < .5
or something like:
if random() <= .5
Thanks for the help.
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.
Ah, the old ‘.5’ problem. Here’s the answer:
If you’re going to divide 10 things into two equal parts, you need 5 things in each part. 0 thru 4 in the first part, 5-9 in the second part. So…
< .5is correct.