From 9b9919d4608f13153c36f83bf24055a2fad6be83 Mon Sep 17 00:00:00 2001 From: abolz Date: Mon, 15 Jan 2018 21:26:03 +0100 Subject: [PATCH] Use max_digits10 in dump_float for float->text->float round-trip --- develop/detail/serializer.hpp | 4 ++-- src/json.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/develop/detail/serializer.hpp b/develop/detail/serializer.hpp index 59b9a60613..7695843597 100644 --- a/develop/detail/serializer.hpp +++ b/develop/detail/serializer.hpp @@ -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::digits10; + // get number of digits for a float -> text -> float round-trip + static constexpr auto d = std::numeric_limits::max_digits10; // the actual conversion std::ptrdiff_t len = snprintf(number_buffer.data(), number_buffer.size(), "%.*g", d, x); diff --git a/src/json.hpp b/src/json.hpp index e1d09f22e5..d01ec00001 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -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::digits10; + // get number of digits for a float -> text -> float round-trip + static constexpr auto d = std::numeric_limits::max_digits10; // the actual conversion std::ptrdiff_t len = snprintf(number_buffer.data(), number_buffer.size(), "%.*g", d, x);