From 5b8aef9623d2d97b0427f4f92c9c1b74a9b945a5 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 31 Dec 2018 09:50:53 +0100 Subject: [PATCH] Yoshimi: found the bug plain flat off by one :-D end pointer must be behind the last array element. Thus we didn't use all state values, and thus our random numbers diverged --- research/try.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/research/try.cpp b/research/try.cpp index a52a2ea15..46855787a 100644 --- a/research/try.cpp +++ b/research/try.cpp @@ -161,7 +161,7 @@ class TrinomialPRNG uint32_t val = *fptr += uint32_t(*rptr); uint32_t result = val >> 1; // Chucking least random bit. // Rationale: it has a less-then optimal repetition cycle. - int32_t *end = &state[62]; + int32_t *end = &state[63]; ++fptr; if (fptr >= end) { @@ -199,7 +199,7 @@ main (int, char**) StdlibPRNG oldGen; TrinomialPRNG newGen; - for (uint64_t seed=0; seed <= UINT32_MAX; ++seed) + for (uint64_t seed=INT32_MAX-100; seed <= UINT32_MAX; ++seed) { oldGen.init(seed); newGen.init(seed);