bn::random class
#include <bn_random.h>

Fast, deterministic random number generator.

Its current implementation is a Marsaglia's xorshf generator.

See https://github.com/raylee/xorshf96/blob/master/xorshf96.c

Public functions

auto get() -> unsigned constexpr
Returns a random unsigned integer greater or equal than 0, updating its internal seed in the process.
auto get_int() -> int constexpr
Returns a random signed integer greater or equal than 0, updating its internal seed in the process.
auto get_fixed() -> fixed constexpr
Returns a random bn::fixed greater or equal than 0, updating its internal seed in the process.
auto get_int(int limit) -> int constexpr
Returns a random signed integer in the range [0..limit), updating its internal seed in the process.
auto get_fixed(fixed limit) -> fixed constexpr
Returns a random bn::fixed in the range [0..limit), updating its internal seed in the process.
auto get_int(int minimum, int limit) -> int constexpr
Returns a random signed integer in the range [minimum..limit), updating its internal seed in the process.
auto get_fixed(fixed minimum, fixed limit) -> fixed constexpr
Returns a random bn::fixed in the range [minimum..limit), updating its internal seed in the process.
void update() constexpr
Updates the value of the internal seed.

Function documentation

int bn::random::get_int(int limit) constexpr

Returns a random signed integer in the range [0..limit), updating its internal seed in the process.

Parameters
limit Returned value is lower than this value.
Returns Random signed integer in the range [0..limit).

fixed bn::random::get_fixed(fixed limit) constexpr

Returns a random bn::fixed in the range [0..limit), updating its internal seed in the process.

Parameters
limit Returned value is lower than this value.
Returns Random bn::fixed in the range [0..limit).

int bn::random::get_int(int minimum, int limit) constexpr

Returns a random signed integer in the range [minimum..limit), updating its internal seed in the process.

Parameters
minimum Returned value is greater or equal than this value.
limit Returned value is lower than this value.
Returns Random signed integer in the range [minimum..limit).

fixed bn::random::get_fixed(fixed minimum, fixed limit) constexpr

Returns a random bn::fixed in the range [minimum..limit), updating its internal seed in the process.

Parameters
minimum Returned value is greater or equal than this value.
limit Returned value is lower than this value.
Returns Random bn::fixed in the range [minimum..limit).