rand.musl #

struct MuslRNG #

struct MuslRNG {
mut:
	state u32 = seed.time_seed_32()
}

MuslRNG ported from https://git.musl-libc.org/cgit/musl/tree/src/prng/rand_r.c

fn (MuslRNG) seed #

fn (mut rng MuslRNG) seed(seed_data []u32)

seed sets the current random state based on seed_data. seed expects seed_data to be only one u32.

fn (MuslRNG) u32 #

fn (mut rng MuslRNG) u32() u32

u32 returns a pseudorandom 32-bit unsigned integer (u32).

fn (MuslRNG) u64 #

fn (mut rng MuslRNG) u64() u64

u64 returns a pseudorandom 64-bit unsigned integer (u64).

fn (MuslRNG) u32n #

fn (mut rng MuslRNG) u32n(max u32) u32

u32n returns a pseudorandom 32-bit unsigned integer u32 in range [0, max).

fn (MuslRNG) u64n #

fn (mut rng MuslRNG) u64n(max u64) u64

u64n returns a pseudorandom 64-bit unsigned integer (u64) in range [0, max).

fn (MuslRNG) u32_in_range #

fn (mut rng MuslRNG) u32_in_range(min u32, max u32) u32

u32_in_range returns a pseudorandom 32-bit unsigned integer (u32) in range [min, max).

fn (MuslRNG) u64_in_range #

fn (mut rng MuslRNG) u64_in_range(min u64, max u64) u64

u64_in_range returns a pseudorandom 64-bit unsigned integer (u64) in range [min, max).

fn (MuslRNG) int #

fn (mut rng MuslRNG) int() int

int returns a 32-bit signed (possibly negative) integer (int).

fn (MuslRNG) i64 #

fn (mut rng MuslRNG) i64() i64

i64 returns a 64-bit signed (possibly negative) integer (i64).

fn (MuslRNG) int31 #

fn (mut rng MuslRNG) int31() int

int31 returns a 31-bit positive pseudorandom integer (int).

fn (MuslRNG) int63 #

fn (mut rng MuslRNG) int63() i64

int63 returns a 63-bit positive pseudorandom integer (i64).

fn (MuslRNG) intn #

fn (mut rng MuslRNG) intn(max int) int

intn returns a 32-bit positive int in range [0, max).

fn (MuslRNG) i64n #

fn (mut rng MuslRNG) i64n(max i64) i64

i64n returns a 64-bit positive integer i64 in range [0, max).

fn (MuslRNG) int_in_range #

fn (mut rng MuslRNG) int_in_range(min int, max int) int

int_in_range returns a 32-bit positive integer int in range [0, max).

fn (MuslRNG) i64_in_range #

fn (mut rng MuslRNG) i64_in_range(min i64, max i64) i64

i64_in_range returns a 64-bit positive integer i64 in range [0, max).

fn (MuslRNG) f32 #

fn (mut rng MuslRNG) f32() f32

f32 returns a pseudorandom f32 value in range [0, 1).

fn (MuslRNG) f64 #

fn (mut rng MuslRNG) f64() f64

f64 returns a pseudorandom f64 value in range [0, 1).

fn (MuslRNG) f32n #

fn (mut rng MuslRNG) f32n(max f32) f32

f32n returns a pseudorandom f32 value in range [0, max).

fn (MuslRNG) f64n #

fn (mut rng MuslRNG) f64n(max f64) f64

f64n returns a pseudorandom f64 value in range [0, max).

fn (MuslRNG) f32_in_range #

fn (mut rng MuslRNG) f32_in_range(min f32, max f32) f32

f32_in_range returns a pseudorandom f32 in range [min, max).

fn (MuslRNG) f64_in_range #

fn (mut rng MuslRNG) f64_in_range(min f64, max f64) f64

i64_in_range returns a pseudorandom i64 in range [min, max).