This repository has been archived on 2022-05-21. You can view files and clone it, but cannot push or open issues or pull requests.
LEFTONE/util/chaos/xorshift.c
falsycat 84c3a02b9a [RELEASE] u22-v03
This version is submitted to U22 breau.
2020-09-14 00:00:00 +00:00

20 lines
417 B
C

#include "./xorshift.h"
#include <stddef.h>
#include <stdint.h>
uint64_t chaos_xorshift(uint64_t seed) {
seed = seed ^ (seed << 13);
seed = seed ^ (seed >> 7);
return seed ^ (seed << 17);
}
float chaos_xorshift_fract(uint64_t seed, uint64_t* next_seed) {
static const uint64_t period = 10000;
seed = chaos_xorshift(seed);
if (next_seed != NULL) *next_seed = seed;
return seed%period*1.f/period;
}