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

rand: document all functions, document range notation form, fix copy-pasta (#7619)

This commit is contained in:
Larpon
2020-12-27 19:06:17 +01:00
committed by GitHub
parent b9df7aae4d
commit ed6ba0a2b8
8 changed files with 169 additions and 154 deletions

View File

@ -5,7 +5,7 @@ module util
import time
// Commonly used constants across RNGs
// Commonly used constants across RNGs - some taken from "Numerical Recipes".
pub const (
lower_mask = u64(0x00000000FFFFFFFF)
max_u32 = 0xFFFFFFFF
@ -16,13 +16,13 @@ pub const (
u63_mask = u64(0x7FFFFFFFFFFFFFFF)
)
// Constants taken from Numerical Recipes
// nr_next returns a next value based on the previous value `prev`.
[inline]
fn nr_next(prev u32) u32 {
return prev * 1664525 + 1013904223
}
// time_seed_array is a utility function that returns the required number of u32s generated from system time
// time_seed_array returns the required number of u32s generated from system time.
[inline]
pub fn time_seed_array(count int) []u32 {
ctime := time.now()
@ -35,13 +35,13 @@ pub fn time_seed_array(count int) []u32 {
return seed_data
}
// time_seed_32 returns a 32-bit seed geenrated from system time
// time_seed_32 returns a 32-bit seed generated from system time.
[inline]
pub fn time_seed_32() u32 {
return time_seed_array(1)[0]
}
// time_seed_64 returns a 64-bit seed geenrated from system time
// time_seed_64 returns a 64-bit seed generated from system time.
[inline]
pub fn time_seed_64() u64 {
seed_data := time_seed_array(2)