diff options
| author | Tyge Løvset <[email protected]> | 2023-03-31 14:00:13 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-03-31 14:00:13 +0200 |
| commit | 4f1d00baf916ceaa27b1a29a80117abdb662d656 (patch) | |
| tree | 14ab36617f78ec4789b4efe1ae412e5f24614c87 | |
| parent | a0a290645828c88597efce80f6b0f5a958cefa89 (diff) | |
| download | STC-modified-4f1d00baf916ceaa27b1a29a80117abdb662d656.tar.gz STC-modified-4f1d00baf916ceaa27b1a29a80117abdb662d656.zip | |
Small change in crand_u64(). Use - instead of ^ in result.
| -rw-r--r-- | include/stc/crand.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/include/stc/crand.h b/include/stc/crand.h index 191d578a..122c1f21 100644 --- a/include/stc/crand.h +++ b/include/stc/crand.h @@ -77,12 +77,12 @@ STC_API double crand_norm(crand_t* rng, crand_norm_t* dist); /* Main crand_t prng */ STC_INLINE uint64_t crand_u64(crand_t* rng) { - enum {LR=24, RS=11, LS=3}; uint64_t *s = rng->state; - const uint64_t out = (s[0] ^ (s[3] += s[4])) + s[1]; - s[0] = s[1] ^ (s[1] >> RS); - s[1] = s[2] + (s[2] << LS); - s[2] = ((s[2] << LR) | (s[2] >> (64 - LR))) + out; - return out; + uint64_t *s = rng->state; + const uint64_t result = s[0] + s[1] - (s[3] += s[4]); + s[0] = s[1] ^ (s[1] >> 11); + s[1] = s[2] + (s[2] << 3); + s[2] = ((s[2] << 24) | (s[2] >> (64 - 24))) + result; + return result; } /* Float64 random number in range [0.0, 1.0). */ |
