Eightomic
Entropy

PRNG 16 B

It's the fastest sequential PRNG versus slower, weaker 16-bit rand() implementations.

Algorithm

Source

#include <stdint.h> struct eightomic_prng_16_b_s { uint32_t a; uint32_t b; }; uint16_t eightomic_prng_16_b(struct eightomic_prng_16_b_s *s) { s->a = ((s->a << 13) | (s->a >> 19)) ^ s->b; s->b += 1111111; return s->a; }

License

It's free and open source.

Reference

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

1: s is the struct eightomic_prng_16_b_s pointer with 2 32-bit unsigned integers s->a and s->b. Each must be initialized with any combination of values including 0.

The return value data type is uint16_t.

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

Explanation

It's the fastest deterministic, sequential PRNG that passes stdin16 PractRand tests with up to 8 million randomized 16-bit numbers.

Furthermore, it guarantees a minimum cycle of 2³² numbers with only 64 bits of state by summing an odd-numbered constant to s->b which results in 2³² different numbers to XOR with s->a.

It's much faster than rand() in standard C implementations without security compliance violations.

A modern implementation of rand() passes PractRand tests up to 512000 randomized numbers, which is 7% of the high-quality randomized numbers that Eightomic PRNG 16 B generates.

Both Xorshift16 "798" and Xorshift32 pass PractRand tests up to 64000 randomized numbers, which is less than 1% of the high-quality randomized numbers that Eightomic PRNG 16 B generates.

When higher-quality 16-bit numbers are required with the same minimum cycle, the lower bits of Eightomic PRNG 32 A and Eightomic PRNG 32 B are suitable.

API

Quantum

Quantum

Spawn non-deterministic, quantum-aligned randomness with an optimal, unique QRNG API.