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

default format for floats #8231

Closed
vicuna opened this issue Jul 25, 2003 · 1 comment
Closed

default format for floats #8231

vicuna opened this issue Jul 25, 2003 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Jul 25, 2003

Original bug ID: 1779
Reporter: administrator
Status: closed
Resolution: won't fix
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Why not make string_of_float be

let float_fmt = ref "%.17g";;

let string_of_float f = valid_float_lexem (format_float !float_fmt f);;

and allow Pervasives.float_fmt be user accessible? Would this slow
things down much?

@vicuna
Copy link
Author

vicuna commented Jul 29, 2003

Comment author: administrator

Why not make string_of_float be

let float_fmt = ref "%.17g";;

let string_of_float f = valid_float_lexem (format_float !float_fmt f);;

and allow Pervasives.float_fmt be user accessible? Would this slow
things down much?

My feeling is that if you care about your floating-point results,
you'll eventually want to display them using printf and the format
appropriate (in precision and style) for your results.

string_of_float is more of a convenience function when one just wants
some printable approximation of a float, e.g. for tracing or logging,
but doesn't really care how good the approximation is.

  • Xavier Leroy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant