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
int_of_string failure #5829
Comments
Comment author: @alainfrisch (Downgrading severity from crash to minor: it's a matter of choice whether those functions should ignore leading/trailing whitespace.) |
Comment author: berenger Consistency in the choice would be nice. |
Comment author: @xavierleroy float_of_string is often more tolerant than int_of_string regarding whitespace and number syntax, because the former relies on strtod() from the C standard library, which itself is not fully specified. This fact was documented in 4.03 for float_of_string: "The format of decimal floating-point numbers is [...] Depending on the execution platforms, other representations of floating-point numbers can be accepted, but should not be relied upon." Making float_of_string stricter just for the sake of consistency is not worth the effort. |
Original bug ID: 5829
Reporter: berenger
Status: resolved (set by @xavierleroy on 2017-02-17T15:43:50Z)
Resolution: not a bug
Priority: normal
Severity: minor
Platform: Intel_x86_64
OS: Linux
OS Version: squeeze/sid
Version: 4.00.0
Fixed in version: 4.03.0
Category: standard library
Related to: #6296 #6649
Bug description
This fails:
int_of_string " 123";;
Exception: (Failure int_of_string).
While this works:
float_of_string " 123";;
I am a little surprised.
Regards,
F.
Steps to reproduce
int_of_string " 1";;
Additional information
These also fail:
int_of_string "1 ";;
Exception: Failure "int_of_string".
float_of_string "1.0 ";;
Exception: Failure "float_of_string".
The text was updated successfully, but these errors were encountered: