nanorand::gen::RandomRange::random_range(lower, upper)
behaves incorrectly (upper
is non-inclusive)
#21
Labels
Milestone
WyRand::new().generate_range::<u32>(0, 1);
seems to always return0
, while the common understanding is that theupper
parameter should be inclusive.This seems to be the understanding of the crate's author as well, as in
shuffle
implementation:target_len - 1
basically means the last value in slice will never be selected as swap target, leading to some bizarre behavior, like shuffling a slice of len 2 always returns reversed slice, instead of giving roughly 50/50 distribution of original and reversed.If the
upper
parameter was indeed meant to be non-inclusive, then I guess the docs should be updated andshuffle
implementation fixed. If it was not, then thegenerate_range
function has to be fixed.Tested on crate v 0.5.2, Rust 1.48.0
EDIT: typos, formatting
The text was updated successfully, but these errors were encountered: