Uh oh!
There was an error while loading. Please reload this page.
pack double and float more size efficient - #1018
Conversation
check also for nan and numeric limits
redboltz
left a comment
There was a problem hiding this comment.
LGTM. I commented some coding stype issue. Please fix them.
| template <typename Stream> | ||
| inline packer<Stream>& packer<Stream>::pack_float(float d) | ||
| { | ||
| if (d == d) { // check for nan |
There was a problem hiding this comment.
| if(d == d) { // check for nan | |
| if(d == d) { // check for nan |
| { | ||
| if (d == d) { // check for nan | ||
| // compare d to limits::max() to avoid undefined behaviour | ||
| if (d >= 0 && d <= std::numeric_limits<uint64_t>::max() && d == uint64_t(d)) { |
There was a problem hiding this comment.
| if(d >= 0 && d <= std::numeric_limits<uint64_t>::max() && d == uint64_t(d)) { | |
| if(d >= 0 && d <= std::numeric_limits<uint64_t>::max() && d == uint64_t(d)) { |
| if (d >= 0 && d <= std::numeric_limits<uint64_t>::max() && d == uint64_t(d)) { | ||
| pack_imp_uint64(uint64_t(d)); | ||
| return *this; | ||
There was a problem hiding this comment.
Please erase empty line above.
| pack_imp_uint64(uint64_t(d)); | ||
| return *this; | ||
| } else if (d >= std::numeric_limits<int64_t>::min() && d == int64_t(d)) { |
There was a problem hiding this comment.
| } elseif(d >= std::numeric_limits<int64_t>::min() && d == int64_t(d)) { | |
| } elseif(d >= std::numeric_limits<int64_t>::min() && d == int64_t(d)) { |
| if (d == d) { // check for nan | ||
| // compare d to limits::max() to avoid undefined behaviour | ||
| if (d >= 0 && d <= std::numeric_limits<uint64_t>::max() && d == uint64_t(d)) { | ||
| pack_imp_uint64(uint64_t(d)); | ||
| return *this; | ||
| } else if (d >= std::numeric_limits<int64_t>::min() && d == int64_t(d)) { | ||
| pack_imp_int64(int64_t(d)); | ||
| return *this; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Please apply the same fix as float.
It seems that CI reports warnings (as errors). Could you fix this? |
Codecov Report
@@ Coverage Diff @@## cpp_master #1018 +/- ##
==============================================
+ Coverage 85.56% 85.60% +0.04%
==============================================
Files 79 79 Lines 5009 5023 +14 ==============================================
+ Hits 4286 4300 +14
Misses 723 723 |
update pack_double and pack_float to avoid warnings
redboltz
commented
Jun 13, 2022
Thank you for updating. Great work! |
Floats may be stored as integers, and msgpack-cpp does that proactively since version 4.1.2, see msgpack/msgpack-c#1018
Floats may be stored as integers in msgpack, and msgpack-cpp does that proactively since version 4.1.2. That broke the `unitCell` angle round trip in `testSave_symmetry__mmtf`. See also: rcsb/mmtf-c#35msgpack/msgpack-c#1018
Floats may be stored as integers in msgpack, and msgpack-cpp does that proactively since version 4.1.2. That broke the `unitCell` angle round trip in `testSave_symmetry__mmtf`. See also: rcsb/mmtf-c#35msgpack/msgpack-c#1018
This is v4.1.1 We can't update beyond v4.1.1 because of what is a breaking change for pdf2msgpack: msgpack/msgpack-c#1018
Floats may be stored as integers, and msgpack-cpp does that proactively since version 4.1.2, see msgpack/msgpack-c#1018
Revert "Merge pull request #1018 from GeorgFritze/cpp_master"
PR for issue #1017