-
Notifications
You must be signed in to change notification settings - Fork 431
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
Uniform::new: range overflow #1380
Comments
changes are coming to this in #1229 |
looks like it is expected, when (high - low) larger than the type can hold. e.g. fn main() {
let scale = f32::MAX - f32::MIN;
println!("{}", f32::MAX); // 340282350000000000000000000000000000000
println!("{}", f32::MIN); // -340282350000000000000000000000000000000
println!("{}", scale); //inf
println!("{}", scale.is_finite()); //false
} |
use rand::distributions::{Distribution, Uniform};
fn main() {
// ok
let r = Uniform::new(0.0, f32::MAX);
// range overflow expected? as MAX - 0 = MAX
let r = Uniform::new_inclusive(0.0, f32::MAX);
// range overflow should be expected, as MAX - MIN > MAX
let r = Uniform::new(f32::MIN, f32::MAX);
} |
The current algorithm for |
Is it expected?
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b1cd60bdecf24a68daca0a86c08a2fbe
The text was updated successfully, but these errors were encountered: