Skip to content

Commit

Permalink
In Splitmix.mixGamma, wrong test for weak Gamma values (#2)
Browse files Browse the repository at this point in the history
The "popcount >= 24" test was taken from the original Splitmix paper,
but is wrong: it should be  "popcount < 24", as explained in the paper
and here http://www.pcg-random.org/posts/bugs-in-splitmix.html

Closes: #2
  • Loading branch information
xavierleroy committed May 14, 2018
1 parent fa170bc commit 44fe85b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- #2: in Splitmix.mixGamma, wrong test for weak Gamma values
2 changes: 1 addition & 1 deletion stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static inline int popcount64(uint64_t x)
CAMLprim uint64_t pringo_mixGamma_unboxed(uint64_t z)
{
z = mix64variant13(z) | 1ULL;
if (popcount64(z ^ (z >> 1)) >= 24) z ^= 0xaaaaaaaaaaaaaaaaULL;
if (popcount64(z ^ (z >> 1)) < 24) z ^= 0xaaaaaaaaaaaaaaaaULL;
return z;
}

Expand Down

0 comments on commit 44fe85b

Please sign in to comment.