You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
isizegb_random_range_isize(gbRandom*r, isizelower_inc, isizehigher_inc) {
u64u=gb_random_gen_u64(r);
isizei=*cast(isize*)&u; // may be negative if u64 has a bit pattern corresponding to a negative isizeisizediff=higher_inc-lower_inc+1;
i %= diff; // modulus of negative i can happen herei+=lower_inc;
returni;
}
A possible fix could be:
But you may want to look into better debiasing or faster biased random number within range generation: https://www.pcg-random.org/posts/bounded-rands.html
The text was updated successfully, but these errors were encountered: