Won't Math.floor(Math.random() * 255) generate uneven probabilities?

Viewed 10776

Was thinking through the logic and it seemed that Math.floor(Math.random() * 255) would generate uneven probabilities of each value being generated.

For example, a number of values can round down to 254, but only when Math.random() generates exactly 1 will the output be 255. How uneven the probabilities are depends on how many decimal digits Math.random() generates to.

Am I incorrect in my thinking here or is there a more balanced way to generate a set of random integers?

2 Answers
Related