-
Notifications
You must be signed in to change notification settings - Fork 120
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
Owl_dataframe shouldn' t use 'string_of_float' #640
Comments
(there is also the '%h' printf format that prints floats in hex form, but that would'be interoperable in CSV, e.g. python wouldn't know to parse it by default in CSV and would leave it as a string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
'string_of_float' only prints 12 digits, which loses some digits, see discussion at ocaml/ocaml#11975.
Using
%.17g
instead should suffice for preserving all digits, however the numbers printed can have extra "ugly" unnecessary digits for commonly used values:To reproduce:
https://ocaml.org/p/base/latest/doc/Base/Float/index.html#val-to_string has a pragmatic approach: try
%.15g
, and check that it round-trips, if not then use%.17g
. See longer explanation at https://github.com/janestreet/base/blob/v0.15.0/src/float.ml#L68-L172P.S.: Npy write/read doesn't have this problem: it preserves the float in its entirety.
The text was updated successfully, but these errors were encountered: