Skip to content
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

Suggestion: float_of_string #2995

Closed
vicuna opened this issue Oct 15, 2001 · 2 comments
Closed

Suggestion: float_of_string #2995

vicuna opened this issue Oct 15, 2001 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Oct 15, 2001

Original bug ID: 581
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Suggestion: float_of_string that throws exception if the number isn't a
float (as int_of_string does).

"The result is undefined if the given string is not a float"
doesn't go well with the concept of a language that helps
the programmer.

The current float_of_string could be renamed to
unsafe_float_of_string.

/mattias

@vicuna
Copy link
Author

vicuna commented Oct 30, 2001

Comment author: administrator

Fixed by replacing atof() by strtod(). -XL, 2001-10-30.

@vicuna vicuna closed this as completed Oct 30, 2001
@vicuna
Copy link
Author

vicuna commented Oct 30, 2001

Comment author: administrator

Suggestion: float_of_string that throws exception if the number isn't a
float (as int_of_string does).

"The result is undefined if the given string is not a float"
doesn't go well with the concept of a language that helps
the programmer.

OK, I grant you that. Turns out that we were using the atof() C
library function, which doesn't detect bad numbers, but ANSI C
specifies a better strtod() function that detects bad numbers. Since
it's ANSI, there's no portability problem. I'll patch the runtime
system to use strtod().

  • Xavier Leroy

@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant