37#ifdef KINC_IMPLEMENTATION_MATH
38#define KINC_IMPLEMENTATION
41#ifdef KINC_IMPLEMENTATION
48static inline uint64_t rotl(
const uint64_t x,
int k) {
49 return (x << k) | (x >> (64 - k));
52static uint64_t s[4] = {1, 2, 3, 4};
55 const uint64_t result = rotl(s[1] * 5, 7) * 9;
57 const uint64_t t = s[1] << 17;
66 s[3] = rotl(s[3], 45);
72 s[0] = (uint64_t)seed;
82 return (int64_t)next();
91 return (value < -LLONG_MAX ? LLONG_MAX : llabs(value)) % (max + 1 - min) + min;
Provides basic functionality that's used all over the place. There's usually no need to manually incl...
KINC_FUNC int64_t kinc_random_get_in(int64_t min, int64_t max)
Returns a value between min and max (both inclusive).
KINC_FUNC int64_t kinc_random_get_max(int64_t max)
Returns a value between 0 and max (both inclusive).
KINC_FUNC int64_t kinc_random_get(void)
Returns a random value.
KINC_FUNC void kinc_random_init(int64_t seed)
Initializes the randomizer with a seed. This is optional but helpful.