[erlang-questions] erlang:phash2(make_ref(), 1 bsl 32)
Bob Ippolito
bob@REDACTED
Thu May 8 06:25:42 CEST 2008
2008/5/7 Per Melin <per.melin@REDACTED>:
> I thought that would be the easiest way to generate an integer unique enough
> for my needs. But it seems to always repeat in 2^18 (262144) iterations.
>
> That is because #Ref<_._.X.Y> gives the same phash2 as #Ref<_._.X+1.Y> in
> any range between 2^20 and 2^32.
>
> Isn't that a little unfortunate?
You could always just use a random number...
crypto:rand_uniform(0, 1 bsl 32).
-bob
More information about the erlang-questions
mailing list