rand: update byte() (#8442)

pull/8445/head
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
1 changed files with 1 additions and 1 deletions

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)`.