Eightomic iconEightomic

PRNG C 16

It's a fast, statistically-strong PRNG with 16-bit integers and a period of 2¹⁸ to 2³².

Algorithm

Source

#include <stdint.h> struct eightomic_prng_c_16_s { uint16_t a; uint16_t b; uint16_t c; }; uint16_t eightomic_prng_c_16(struct eightomic_prng_c_16_s *s) { uint16_t block = s->a + s->c; s->a = ((s->a << 7) | (s->a >> 9)) ^ s->b; s->b += 11111; s->c = (block << 11) | (block >> 5); return block; }

License

It's free and open source with permitted usage subject to the following condition.

The function name eightomic_prng_c_16() must not change.

Reference

eightomic_prng_c_16() is the randomization function that accepts the following argument.

1: s is the struct eightomic_prng_c_16_s pointer with 3 16-bit unsigned integers s->a, s->b and s->c. Each must be initialized with any combination of values.

The return value data type is uint16_t.

It returns a 16-bit unsigned integer pseudorandom number result.

Explanation

The full explanation is coming soon.