Merge pull request #2121 from gistrec/fix_compilation_error_msvc

Fixed a compilation error in MSVC
This commit is contained in:
Niels Lohmann 2020-05-19 13:55:37 +02:00 committed by GitHub
commit a861bdb81f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View file

@ -195,7 +195,7 @@ class binary_writer
else else
{ {
if (static_cast<double>(j.m_value.number_float) >= static_cast<double>(std::numeric_limits<float>::lowest()) and if (static_cast<double>(j.m_value.number_float) >= static_cast<double>(std::numeric_limits<float>::lowest()) and
static_cast<double>(j.m_value.number_float) <= static_cast<double>(std::numeric_limits<float>::max()) and static_cast<double>(j.m_value.number_float) <= static_cast<double>((std::numeric_limits<float>::max)()) and
static_cast<double>(static_cast<float>(j.m_value.number_float)) == static_cast<double>(j.m_value.number_float)) static_cast<double>(static_cast<float>(j.m_value.number_float)) == static_cast<double>(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

@ -12206,7 +12206,7 @@ class binary_writer
else else
{ {
if (static_cast<double>(j.m_value.number_float) >= static_cast<double>(std::numeric_limits<float>::lowest()) and if (static_cast<double>(j.m_value.number_float) >= static_cast<double>(std::numeric_limits<float>::lowest()) and
static_cast<double>(j.m_value.number_float) <= static_cast<double>(std::numeric_limits<float>::max()) and static_cast<double>(j.m_value.number_float) <= static_cast<double>((std::numeric_limits<float>::max)()) and
static_cast<double>(static_cast<float>(j.m_value.number_float)) == static_cast<double>(j.m_value.number_float)) static_cast<double>(static_cast<float>(j.m_value.number_float)) == static_cast<double>(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

@ -925,7 +925,7 @@ TEST_CASE("CBOR")
} }
SECTION("3.40282e+38(max float)") SECTION("3.40282e+38(max float)")
{ {
float v = std::numeric_limits<float>::max(); float v = (std::numeric_limits<float>::max)();
json j = v; json j = v;
std::vector<uint8_t> expected = std::vector<uint8_t> expected =
{ {
@ -953,7 +953,7 @@ TEST_CASE("CBOR")
} }
SECTION("1 + 3.40282e+38(more than max float)") SECTION("1 + 3.40282e+38(more than max float)")
{ {
double v = static_cast<double>(std::numeric_limits<float>::max()) + 0.1e+34; double v = static_cast<double>((std::numeric_limits<float>::max)()) + 0.1e+34;
json j = v; json j = v;
std::vector<uint8_t> expected = std::vector<uint8_t> expected =
{ {