[erlang-questions] erlang:phash2(make_ref(), 1 bsl 32)
Hans Bolinder
hans.bolinder@REDACTED
Thu May 8 16:30:26 CEST 2008
[Per Melin:]
> 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.
Once upon a time references were 18 bits wide, but there is no reason
why a hash function should not hash all bits. It's probably a
copy/paste bug.
I've added a comment to the source code. Thanks for pointing it out.
Best regards,
Hans Bolinder, Erlang/OTP, Ericsson
More information about the erlang-questions
mailing list