1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

rand: move constants from rand.util to a new module rand.constants (#8408)

This commit is contained in:
Subhomoy Haldar
2021-01-29 15:27:30 +05:30
committed by GitHub
parent d012f2713b
commit c5a18812e2
7 changed files with 36 additions and 33 deletions

View File

@@ -4,7 +4,7 @@
module pcg32
import rand.seed
import rand.util
import rand.constants
// PCG32RNG ported from http://www.pcg-random.org/download.html,
// https://github.com/imneme/pcg-c-basic/blob/master/pcg_basic.c, and
@@ -176,13 +176,13 @@ pub fn (mut rng PCG32RNG) i64_in_range(min i64, max i64) i64 {
// f32 returns a pseudorandom `f32` value in range `[0, 1)`.
[inline]
pub fn (mut rng PCG32RNG) f32() f32 {
return f32(rng.u32()) / util.max_u32_as_f32
return f32(rng.u32()) / constants.max_u32_as_f32
}
// f64 returns a pseudorandom `f64` value in range `[0, 1)`.
[inline]
pub fn (mut rng PCG32RNG) f64() f64 {
return f64(rng.u64()) / util.max_u64_as_f64
return f64(rng.u64()) / constants.max_u64_as_f64
}
// f32n returns a pseudorandom `f32` value in range `[0, max)`.