Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
int_of_string failure #5829
Original bug ID: 5829
While this works:
I am a little surprised.
Steps to reproduce
int_of_string " 1";;
These also fail:
int_of_string "1 ";;
Exception: Failure "int_of_string".
float_of_string "1.0 ";;
Exception: Failure "float_of_string".
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.