Commit graph

8 commits

Author SHA1 Message Date
abolz 9b9919d460 Use max_digits10 in dump_float for float->text->float round-trip 2018-01-15 21:26:03 +01:00
abolz 9f7c2c04c8 Use the Grisu2 algorithm for formatting 'float's and 'double's 2018-01-15 21:07:26 +01:00
abolz 332f352033 Add an implementation of the Grisu2 algorithm for binary to decimal floating-point conversion
This is an attempt to fix #360. The algorithm produces
decimal representations which are guaranteed to roundtrip
and in ~99.8% actually produces the shortest possible
representation. So this is a nice compromise between using
a precision of digits10 and max_digits10.

Note 1:

The implementation only works for IEEE single/double precision
numbers. So the old implementation is kept for compatibility
with non-IEEE implementations and 'long double'.

Note 2:

If number_float_t is 'float', not all serialized numbers can
be recovered using strtod (strtof works, though). (There is
exactly one such number and the result is off by 1 ulp.)
This can be avoided by changing the implementation (the fix
is trivial), but then the resulting decimal numbers are not
exactly short.
2018-01-15 21:07:26 +01:00
Théo DELRIEU 84bffd5d36
move amalgamate tool to third_party folder 2018-01-13 13:05:42 +01:00
Niels Lohmann a66b2d20c6
🚨 removed linter warnings for Python code 2018-01-13 11:15:23 +01:00
Niels Lohmann f4a55f26b0
added amalgamate Python script 2018-01-13 10:59:49 +01:00
Niels Lohmann 85173f5627
🔨 some clean up 2018-01-10 10:18:31 +01:00
Niels Lohmann 0a2920e0fd
♻️ reorganized code 2018-01-09 18:30:02 +01:00