Expected Behavior
When serializing floats you have to decide which precision to use. The sexp (sexplib0) and json (yojson) serializers for example will use a varying precision to guarantee that the value could in theory be parsed back to the same value.
Granted Dyn is not meant to be "parsed back", but I've taken a liking to this module as of late and would like to use more generally as a printer to debug values, in expect tests, etc. I'd like to request to import a similar logic from the sexp or yojson libs to dyn and print floats with the precision they require.
Actual Behavior
Currently Dyn.float is printed with a hard coded "12g" (via Stdlib.string_of_float) which loses information. It will print as equal floats that are not, causing some confusion.
Reproduction
This should be visible with a value that doesn't round-trip with 12g.
Specifications
- Version of
dune (output of dune --version): latest
- Version of
ocaml (output of ocamlc --version): 5.3
- Operating system (distribution and version): ubuntu-something
Expected Behavior
When serializing floats you have to decide which precision to use. The sexp (sexplib0) and json (yojson) serializers for example will use a varying precision to guarantee that the value could in theory be parsed back to the same value.
Granted
Dynis not meant to be "parsed back", but I've taken a liking to this module as of late and would like to use more generally as a printer to debug values, in expect tests, etc. I'd like to request to import a similar logic from the sexp or yojson libs to dyn and print floats with the precision they require.Actual Behavior
Currently
Dyn.floatis printed with a hard coded "12g" (viaStdlib.string_of_float) which loses information. It will print as equal floats that are not, causing some confusion.Reproduction
This should be visible with a value that doesn't round-trip with 12g.
Specifications
dune(output ofdune --version): latestocaml(output ofocamlc --version): 5.3