-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8310,16 +8310,7 @@ class basic_json | |
static_assert(d == 6 or d == 15 or d == 16 or d == 17, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
TurpentineDistillery
|
||
"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(); | ||
|
1 comment
on commit 7d14f16
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
snprintf(m_buf.data(), m_buf.size(), "%.*g", d, x);
- sorcery!
@TurpentineDistillery Which number types did you have in mind to check for 16 and 17? I only could find 6 for float and 15 for double.