From: Tim Little on
On 2010-05-02, William Hughes <wpihughes(a)hotmail.com> wrote:
> On May 2, 3:56am, Tim Little <t...(a)little-possums.net> wrote:
>> Math.round(Math.random()*11) will sometimes give the result
>> 11,
>
> Given that Math.random provides values from [0,1) I do not see the
> "will".

Suppose Math.random() produces some value in the range (21/22, 1).
Then multiplying by 11 yields a value in the range (10.5, 11), which
Math.round() rounds to the nearest integer, 11.

That's why Math.round() is simply incorrect for this application,
regardless of any questions of distribution of integers within the
range [0,10].


- Tim