update msgpack_basic test for compact double packaging

update pack_double and pack_float to avoid warnings
This commit is contained in:
GeorgFritze
2022-06-07 09:46:39 +02:00
parent d5c837b612
commit d59e1d7716
2 changed files with 20 additions and 4 deletions

View File

@@ -1140,10 +1140,10 @@ inline packer<Stream>& packer<Stream>::pack_float(float d)
{
if(d == d) { // check for nan
// compare d to limits to avoid undefined behaviour
if(d >= 0 && d <= std::numeric_limits<uint64_t>::max() && d == uint64_t(d)) {
if(d >= 0 && d <= float(std::numeric_limits<uint64_t>::max()) && d == float(uint64_t(d))) {
pack_imp_uint64(uint64_t(d));
return *this;
} else if(d >= std::numeric_limits<int64_t>::min() && d == int64_t(d)) {
} else if(d >= float(std::numeric_limits<int64_t>::min()) && d == float(int64_t(d))) {
pack_imp_int64(int64_t(d));
return *this;
}
@@ -1162,10 +1162,10 @@ inline packer<Stream>& packer<Stream>::pack_double(double d)
{
if(d == d) { // check for nan
// compare d to limits to avoid undefined behaviour
if(d >= 0 && d <= std::numeric_limits<uint64_t>::max() && d == uint64_t(d)) {
if(d >= 0 && d <= double(std::numeric_limits<uint64_t>::max()) && d == double(uint64_t(d))) {
pack_imp_uint64(uint64_t(d));
return *this;
} else if(d >= std::numeric_limits<int64_t>::min() && d == int64_t(d)) {
} else if(d >= double(std::numeric_limits<int64_t>::min()) && d == double(int64_t(d))) {
pack_imp_int64(int64_t(d));
return *this;
}