tc39 / proposal-seeded-random

Proposal for an options argument to be added to JS's Math.random() function, and some options to start it with.
MIT License
156 stars 6 forks source link

Output range should be [0, 1), not [0, 1] #10

Closed davidje13 closed 5 years ago

davidje13 commented 5 years ago

Math.random() never returns 1.0, so this API should be the same. This avoids bias when truncating to integers after multiplying: Math.floor(Math.random() * 6) + 1 will never be 7.

From the wording I think this is just a typo in the proposal, because it suggests it is the same as Math.random;

These values must approximate a uniform distribution over the range [0,1], same as Math.random().

The range should be [0,1)