diff --git a/runners/bench_runner.c b/runners/bench_runner.c index 44a3637f..384995d9 100644 --- a/runners/bench_runner.c +++ b/runners/bench_runner.c @@ -587,6 +587,11 @@ uint32_t bench_prng(uint32_t *state) { // A simple xorshift32 generator, easily reproducible. Keep in mind // determinism is much more important than actual randomness here. uint32_t x = *state; + // must be non-zero, use uintmax here so that seed=0 is different + // from seed=1 and seed=range(0,n) makes a bit more sense + if (x == 0) { + x = -1; + } x ^= x << 13; x ^= x >> 17; x ^= x << 5; diff --git a/runners/test_runner.c b/runners/test_runner.c index 4e1eeb7f..ba9ca95a 100644 --- a/runners/test_runner.c +++ b/runners/test_runner.c @@ -603,6 +603,11 @@ uint32_t test_prng(uint32_t *state) { // A simple xorshift32 generator, easily reproducible. Keep in mind // determinism is much more important than actual randomness here. uint32_t x = *state; + // must be non-zero, use uintmax here so that seed=0 is different + // from seed=1 and seed=range(0,n) makes a bit more sense + if (x == 0) { + x = -1; + } x ^= x << 13; x ^= x >> 17; x ^= x << 5;