Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In 0.7.0, WyRand can generate values below range when using generate_range. #50

Closed
cyeganeh01248 opened this issue Apr 24, 2024 · 1 comment

Comments

@cyeganeh01248
Copy link

Using this PoC, you can see that the expected range would be 50-100. However, when run using version 0.7.0, this sometimes generates values of 49. It doesn't matter what the lower bound is. It does this for i8, i16, i32, i64, and isize.

Package versions 0.6.0 && 0.6.1 do not produce this bug.

use nanorand::{Rng, WyRand};

fn main() {
    let mut test_seed = 0;
    let mi = 50;
    let ma = 100;
    'outer: loop {
        let mut rng = WyRand::new_seed(test_seed);
        for j in 0..128 {
            let v = rng.generate_range(mi..ma);
            if v < mi || v >= ma {
                println!("{} {} {}", test_seed, j, v);
                // break 'outer;
            }
        }
        test_seed += 1;
    }
}
@cyeganeh01248
Copy link
Author

Just noticed issue #45, Closing as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant