[erlang-questions] [ANN] Erlang UUID
Richard O'Keefe
<>
Sat Mar 3 06:02:04 CET 2012
On 3/03/2012, at 1:32 PM, Michael Truog wrote:
> If you use this implementation, then it would provide 408 bits of randomness, uniformly distributed.
I don't see how it can. Just because all the numbers are in a given range does not mean that
all the numbers in that range are possible. The Wichmann-Hill generator has a state with
4 31-bit numbers, meaning that you can't possibly get more than 124 bits out of it. If you
really get more, you have a different algorithm.
Using 64-bit integer arithmetic, the algorithm looks like
a = (a * 11600LL) % 2147483579;
b = (b * 47003LL) % 2147483543;
c = (c * 23000LL) % 2147483423;
d = (d * 33000LL) % 2147483123;
w = a/2147483579.0 + b/2147483543.0
+ c/2147483423.0 + d/2147483123.0;
if (w >= 2.0) w -= 2.0;
if (w >= 1.0) w -= 1.0;
return w;
More information about the erlang-questions
mailing list