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

rand: add missing rand.u16(), update doc comments, add test

This commit is contained in:
Delyan Angelov
2023-05-22 13:15:07 +03:00
parent 3a09142ace
commit c382f4d310
2 changed files with 35 additions and 5 deletions

View File

@ -505,6 +505,16 @@ pub fn seed(seed []u32) {
default_rng.seed(seed)
}
// u8 returns a uniformly distributed pseudorandom 8-bit unsigned positive `u8`.
pub fn u8() u8 {
return default_rng.u8()
}
// u16 returns a uniformly distributed pseudorandom 16-bit unsigned positive `u16`.
pub fn u16() u16 {
return default_rng.u16()
}
// u32 returns a uniformly distributed `u32` in range `[0, 2³²)`.
pub fn u32() u32 {
return default_rng.u32()
@ -550,11 +560,6 @@ pub fn intn(max int) !int {
return default_rng.intn(max)
}
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
pub fn u8() u8 {
return default_rng.u8()
}
// int_in_range returns a uniformly distributed pseudorandom 32-bit signed int in range `[min, max)`.
// Both `min` and `max` can be negative, but we must have `min < max`.
pub fn int_in_range(min int, max int) !int {