Skip to content

Instantly share code, notes, and snippets.

@evanw
Created April 1, 2018 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evanw/9e2d125970b075ac56a37bf36d274825 to your computer and use it in GitHub Desktop.
Save evanw/9e2d125970b075ac56a37bf36d274825 to your computer and use it in GitHub Desktop.
Rust's float parser has correctness issues
fn main() {
// Ok(0.000000000...0000000005)
println!("{:?}", "4.9406564584124654e-324".parse::<f64>());
// WTF???
// Err(ParseFloatError { kind: Invalid })
println!("{:?}", "4.94065645841246545e-324".parse::<f64>());
// Ok(0.000000000...0000000005)
println!("{:?}", "4.9406564584124655e-324".parse::<f64>());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment