Closed vrde closed 3 years ago
The Bounded function calculates a threshold value that is -bound % bound:
Bounded
threshold
-bound % bound
https://github.com/MichaelTJones/pcg/blob/df440c6ed7ed8897ac98a408365e5e89c7becf1a/pcg32.go#L51-L62
I'm not sure if I'm missing anything obvious, but -bound % bound will always be 0. If that's the case the following if will always be true, so the random number r will suffer the modulo bias.
0
if
r
Nevermind, I now see that the behavior using uint instead of int is different.
uint
int
The
Bounded
function calculates athreshold
value that is-bound % bound
:https://github.com/MichaelTJones/pcg/blob/df440c6ed7ed8897ac98a408365e5e89c7becf1a/pcg32.go#L51-L62
I'm not sure if I'm missing anything obvious, but
-bound % bound
will always be0
. If that's the case the followingif
will always be true, so the random numberr
will suffer the modulo bias.