WIP Background
This commit is contained in:
25
src/values/MyRand.cpp
Normal file
25
src/values/MyRand.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
static uint32_t rprand_state[4] = {0};
|
||||
|
||||
static inline uint32_t my_rotate_left(const uint32_t x, int k)
|
||||
{
|
||||
return (x << k) | (x >> (32 - k));
|
||||
}
|
||||
|
||||
uint32_t my_rprand_xoshiro(void)
|
||||
{
|
||||
const uint32_t result = my_rotate_left(rprand_state[1] * 5, 7) * 9;
|
||||
const uint32_t t = rprand_state[1] << 9;
|
||||
|
||||
rprand_state[2] ^= rprand_state[0];
|
||||
rprand_state[3] ^= rprand_state[1];
|
||||
rprand_state[1] ^= rprand_state[2];
|
||||
rprand_state[0] ^= rprand_state[3];
|
||||
|
||||
rprand_state[2] ^= t;
|
||||
|
||||
rprand_state[3] = my_rotate_left(rprand_state[3], 11);
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user