Skip to content

Commit

Permalink
Use max_digits10 in dump_float for float->text->float round-trip
Browse files Browse the repository at this point in the history
  • Loading branch information
abolz committed Jan 15, 2018
1 parent 810f81b commit 9b9919d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions develop/detail/serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,8 @@ class serializer

void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/)
{
// get number of digits for a text -> float -> text round-trip
static constexpr auto d = std::numeric_limits<number_float_t>::digits10;
// get number of digits for a float -> text -> float round-trip
static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;

// the actual conversion
std::ptrdiff_t len = snprintf(number_buffer.data(), number_buffer.size(), "%.*g", d, x);
Expand Down
4 changes: 2 additions & 2 deletions src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8136,8 +8136,8 @@ class serializer

void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/)
{
// get number of digits for a text -> float -> text round-trip
static constexpr auto d = std::numeric_limits<number_float_t>::digits10;
// get number of digits for a float -> text -> float round-trip
static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;

// the actual conversion
std::ptrdiff_t len = snprintf(number_buffer.data(), number_buffer.size(), "%.*g", d, x);
Expand Down

0 comments on commit 9b9919d

Please sign in to comment.