Skip to content

Commit a2e93ec

Browse files
authored
rand.xoroshiro128pp: prevent generation of extra zeros in u16() (#26229)
1 parent 2ea7b02 commit a2e93ec

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

vlib/rand/xoroshiro128pp/xoros128pp.v

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ pub fn (mut rng XOROS128PPRNG) u8() u8 {
4848
ans := rng.u64()
4949
rng.buffer = ans >> 8
5050
rng.bytes_left = 7
51-
value := u8(ans)
52-
return value
51+
return u8(ans)
5352
}
5453

5554
// u16 returns a pseudorandom 16-bit unsigned integer (`u16`).
@@ -62,7 +61,7 @@ pub fn (mut rng XOROS128PPRNG) u16() u16 {
6261
return value
6362
}
6463
ans := rng.u64()
65-
rng.buffer = u32(ans >> 16)
64+
rng.buffer = ans >> 16
6665
rng.bytes_left = 6
6766
return u16(ans)
6867
}

0 commit comments

Comments
 (0)