Fix comparission between integers and floats
Until now it depended on the parameter-order whether integers and floats were compared as integers or floats. Appart from being not logical, this might even have meant that the provided “order” was in fact not that. (not sure here, but I like to be carefull)
This commit is contained in:
parent
306695dd25
commit
d2771eb1bb
2 changed files with 8 additions and 8 deletions
|
@ -1906,8 +1906,8 @@ class basic_json
|
|||
}
|
||||
else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
|
||||
{
|
||||
return lhs.m_value.number_integer ==
|
||||
static_cast<number_integer_t>(rhs.m_value.number_float);
|
||||
return approx(static_cast<number_float_t>(lhs.m_value.number_integer),
|
||||
rhs.m_value.number_float);
|
||||
}
|
||||
else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
|
||||
{
|
||||
|
@ -1967,8 +1967,8 @@ class basic_json
|
|||
}
|
||||
else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
|
||||
{
|
||||
return lhs.m_value.number_integer <
|
||||
static_cast<number_integer_t>(rhs.m_value.number_float);
|
||||
return static_cast<number_float_t>(lhs.m_value.number_integer) <
|
||||
rhs.m_value.number_float;
|
||||
}
|
||||
else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
|
||||
{
|
||||
|
|
|
@ -1906,8 +1906,8 @@ class basic_json
|
|||
}
|
||||
else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
|
||||
{
|
||||
return lhs.m_value.number_integer ==
|
||||
static_cast<number_integer_t>(rhs.m_value.number_float);
|
||||
return approx(static_cast<number_float_t>(lhs.m_value.number_integer),
|
||||
rhs.m_value.number_float);
|
||||
}
|
||||
else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
|
||||
{
|
||||
|
@ -1967,8 +1967,8 @@ class basic_json
|
|||
}
|
||||
else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
|
||||
{
|
||||
return lhs.m_value.number_integer <
|
||||
static_cast<number_integer_t>(rhs.m_value.number_float);
|
||||
return static_cast<number_float_t>(lhs.m_value.number_integer) <
|
||||
rhs.m_value.number_float;
|
||||
}
|
||||
else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue