From 44fe85b52892ca00bd482c76282426fbf830b998 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Mon, 14 May 2018 09:46:42 +0200 Subject: [PATCH] In Splitmix.mixGamma, wrong test for weak Gamma values (#2) 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 --- Changes | 1 + stubs.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Changes diff --git a/Changes b/Changes new file mode 100644 index 0000000..e73a198 --- /dev/null +++ b/Changes @@ -0,0 +1 @@ +- #2: in Splitmix.mixGamma, wrong test for weak Gamma values diff --git a/stubs.c b/stubs.c index af75b84..fd8de32 100644 --- a/stubs.c +++ b/stubs.c @@ -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; }