1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-13 20:21:48 +03:00

Merge upstream commits and resolve conflicts

This commit is contained in:
Trevor Welsby
2016-01-25 02:42:20 +10:00
5 changed files with 33 additions and 14 deletions

View File

@ -5873,10 +5873,16 @@ class basic_json
case value_t::number_float:
{
// 15 digits of precision allows round-trip IEEE 754
// string->double->string; to be safe, we read this value from
// std::numeric_limits<number_float_t>::digits10
o << std::setprecision(std::numeric_limits<number_float_t>::digits10) << m_value.number_float;
// If the number is an integer then output as a fixed with with precision 1
// to output "0.0", "1.0" etc as expected for some round trip tests otherwise
// 15 digits of precision allows round-trip IEEE 754 string->double->string;
// to be safe, we read this value from std::numeric_limits<number_float_t>::digits10
if (std::fmod(m_value.number_float, 1) == 0) o << std::fixed << std::setprecision(1);
else {
o.unsetf(std::ios_base::floatfield); // std::defaultfloat not supported in gcc version < 5
o << std::setprecision(std::numeric_limits<double>::digits10);
}
o << m_value.number_float;
return;
}