1
0
mirror of https://github.com/nlohmann/json synced 2024-11-10 14:30:08 +00:00

compare against max float and min float before converting

This commit is contained in:
chenguoping 2020-05-15 21:47:59 +08:00
parent 779a0ec7df
commit 5dd27f1a9f
2 changed files with 4 additions and 4 deletions

View File

@ -194,8 +194,8 @@ class binary_writer
} }
else else
{ {
if (j.m_value.number_float > -std::numeric_limits<float>::min() and if (j.m_value.number_float >= std::numeric_limits<float>::lowest() and
j.m_value.number_float < std::numeric_limits<float>::max() and j.m_value.number_float <= std::numeric_limits<float>::max() and
static_cast<double>(static_cast<float>(j.m_value.number_float)) == j.m_value.number_float) static_cast<double>(static_cast<float>(j.m_value.number_float)) == j.m_value.number_float)
{ {
oa->write_character(get_cbor_float_prefix(static_cast<float>(j.m_value.number_float))); oa->write_character(get_cbor_float_prefix(static_cast<float>(j.m_value.number_float)));

View File

@ -12143,8 +12143,8 @@ class binary_writer
} }
else else
{ {
if (j.m_value.number_float > -std::numeric_limits<float>::min() and if (j.m_value.number_float >= std::numeric_limits<float>::lowest() and
j.m_value.number_float < std::numeric_limits<float>::max() and j.m_value.number_float <= std::numeric_limits<float>::max() and
static_cast<double>(static_cast<float>(j.m_value.number_float)) == j.m_value.number_float) static_cast<double>(static_cast<float>(j.m_value.number_float)) == j.m_value.number_float)
{ {
oa->write_character(get_cbor_float_prefix(static_cast<float>(j.m_value.number_float))); oa->write_character(get_cbor_float_prefix(static_cast<float>(j.m_value.number_float)));