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

rand: update byte() (#8442)

This commit is contained in:
Subhomoy Haldar 2021-01-30 18:49:14 +05:30 committed by GitHub
parent 8c70920695
commit 7e3b3a9efc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,7 +73,7 @@ pub fn intn(max int) int {
// byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`. // byte returns a uniformly distributed pseudorandom 8-bit unsigned positive `byte`.
pub fn byte() byte { pub fn byte() byte {
return byte(default_rng.intn(256)) return byte(default_rng.u32() & 0xff)
} }
// int_in_range returns a uniformly distributed pseudorandom 32-bit signed int in range `[min, max)`. // int_in_range returns a uniformly distributed pseudorandom 32-bit signed int in range `[min, max)`.