summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstderr64 <stderr64@null.net>2026-09-24 21:41:53 +0300
committerstderr64 <stderr64@null.net>2026-09-24 21:41:53 +0300
commit9c3a0e5eb91141ce145cecded932b2eadda299d7 (patch)
treeb6e880b8c62f008b9e578cfd9238369fa4c7bf89
parentf9a30793a176523990415ef0be47dbd1296ab5cc (diff)
downloadlibxorshift-9c3a0e5eb91141ce145cecded932b2eadda299d7.tar.gz
libxorshift-9c3a0e5eb91141ce145cecded932b2eadda299d7.tar.zst
Taking the first 4 bits for next state actually gives even better results in tests HEAD master
-rw-r--r--xorshift.c4
1 files 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 ){