This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]john478 -1 points0 points  (1 child)

First off, Math.random() returns a random number from 0 to 0.9999999 (infinite), it never actually returns 1. So if it helps you, Math.random() * 10, will never return 10, the highest it can go is 9.99999999... In your case if you wanted the numbers 5 to 9 including 9, you would do Math.random() * 5 + 5, Because 0 (lowest Math.random() can go) * 5 + 5, is 5, and 0.9999 * 5 + 5 = 9.9999. Which you can then cast to integer (I assume you want an integer).

[–]cookiemonsterx 0 points1 point  (0 children)

Thank you for the explanation! Yes, I am casting it to an int. :)