diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index b8b5a572..163e88d9 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -194,8 +194,8 @@ class binary_writer } else { - if (j.m_value.number_float > -std::numeric_limits::min() and - j.m_value.number_float < std::numeric_limits::max() and + if (j.m_value.number_float >= std::numeric_limits::lowest() and + j.m_value.number_float <= std::numeric_limits::max() and static_cast(static_cast(j.m_value.number_float)) == j.m_value.number_float) { oa->write_character(get_cbor_float_prefix(static_cast(j.m_value.number_float))); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 23ae8105..b30e4560 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -12143,8 +12143,8 @@ class binary_writer } else { - if (j.m_value.number_float > -std::numeric_limits::min() and - j.m_value.number_float < std::numeric_limits::max() and + if (j.m_value.number_float >= std::numeric_limits::lowest() and + j.m_value.number_float <= std::numeric_limits::max() and static_cast(static_cast(j.m_value.number_float)) == j.m_value.number_float) { oa->write_character(get_cbor_float_prefix(static_cast(j.m_value.number_float)));