From 9c3a0e5eb91141ce145cecded932b2eadda299d7 Mon Sep 17 00:00:00 2001 From: stderr64 Date: Thu, 24 Sep 2026 21:41:53 +0300 Subject: Taking the first 4 bits for next state actually gives even better results in tests --- xorshift.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xorshift.c b/xorshift.c index c11cc7a..ac4d087 100644 --- a/xorshift.c +++ b/xorshift.c @@ -22,14 +22,14 @@ __attribute__((visibility("default"))) bool initialize_states(){ errno = EIO; return false; } - global_rng_state.state_idx = global_rng_state.states[7] & 0x0f; + global_rng_state.state_idx = global_rng_state.states[7] >> 28; errno = 0; return true; } __attribute__((visibility("default"))) uint32_t get_random_output(){ size_t use_state = global_rng_state.state_idx; - global_rng_state.state_idx = global_rng_state.states[use_state] & 0x0f; + global_rng_state.state_idx = global_rng_state.states[use_state] >> 28; if ( global_rng_state.gen_period_ctr >= 0xffffffff ){ global_rng_state.period_end_ctr++; if ( global_rng_state.period_end_ctr >= 16 ){ -- cgit v1.3.1-10-gc9f91