Created
April 1, 2018 02:33
-
-
Save evanw/9e2d125970b075ac56a37bf36d274825 to your computer and use it in GitHub Desktop.
Rust's float parser has correctness issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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