[erlang-bugs] Repeatable output from crypto:rand_uniform with negative Low value

Sverker Eriksson sverker@REDACTED
Wed Sep 7 11:46:50 CEST 2011


Robert Newson wrote:
> Hi,
>
> I've noticed that repeated calls to crypto:rand_uniform return the
> same values if Low is negative and High is (approximately) equal to
> -Low, and the answer is also outside of the requested range.
>
> e.g,;
>
> 7> crypto:rand_uniform(-10000,10000).
> 65536
> 8> crypto:rand_uniform(-10000,10000).
> 65536
> 9> crypto:rand_uniform(-10000,10000).
> 65536
>
> This is with R14B03.
>
>   
I've fixed rand_uniform to handle negative number for R14B04.
Also made it throw badarg if the second argument 'Hi' is not larger than 
the first 'Lo'.

/Sverker, Erlang/OTP




More information about the erlang-bugs mailing list