You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'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:
(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)
'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: