-
Notifications
You must be signed in to change notification settings - Fork 13k
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
float::from_str returns 0 for one space, and NaN for multiple spaces #1089
Comments
Are we sure that spaces should parse? uint::from_str doesn't look like it parses space (actually it looks like it might do something crazy). |
Good question. For comparison, However, Rust's implementation is definitely not designed to do so, so it seems like an accident that it allows a single space in some cases. It should be changed to either allow or disallow any amount of leading and trailing space. |
That sounds like good precedent to me. We should probably make sure they allow all whitespace characters then (as defined in char::is_whitespace) |
Some more quirks:
|
Discard leading and trailing whitespace, for consistency with C/JS/Java/etc. Also, don't allow floating point numbers that start or end with 'e'.
Discard leading and trailing whitespace, for consistency with C/JS/Java/etc. Also, don't allow floating point numbers that start or end with 'e'.
Fixed by #1103 |
Add custom rustc driver that uses cg_clif
We were trying to figure out the values of those properties during runtime, which is not possible. Fix the code to look for the information in the vtable instead.
float::from_str(" ")
(the input is a string of two space characters) returns NaN in Rust. It should return 0.0.float::from_str(" ")
(with just one space character) returns 0.0.There is a test in stdtest/float.rs that should have caught this bug, but it is falsely passing because (NaN == 0.0) is true (#1083).
The text was updated successfully, but these errors were encountered: