1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-10 22:00:59 +03:00

🚑 fix for #465

This commit is contained in:
Niels Lohmann
2017-02-20 22:48:27 +01:00
parent b04543ecc5
commit 7d14f167b8
4 changed files with 27 additions and 22 deletions

View File

@ -8310,16 +8310,7 @@ class basic_json
static_assert(d == 6 or d == 15 or d == 16 or d == 17,
"unexpected NumberType");
static constexpr auto fmt = d == 6 ? "%.7g"
: d == 15 ? "%.16g"
: d == 16 ? "%.17g"
: d == 17 ? "%.18g"
: "%.19g";
// I'm not sure why we need to +1 the precision,
// but without it there's a unit-test that fails
// that asserts precision of the output
snprintf(m_buf.data(), m_buf.size(), fmt, x);
snprintf(m_buf.data(), m_buf.size(), "%.*g", d, x);
// read information from locale
const auto loc = localeconv();