You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot serialize small floats in msgpack float format #1111
Bug description
I stumbled over #1018, since I was not expecting my float values to be serialized as int64.
Furthermore, there currently does not seem to be a way to force serialization of a float to the float msgpack format.
I find this a bit inconsistent API-wise, because there's pack_fix_int32 (and others) for integers, which does force a certain serialization width.
Version: msgpack-cxx 6.1.0, but the problem is probably present since cpp-4.1.2.
Regarding the spec, I interpreted the following such that for "an object of a certain source type, serializers SHOULD use the format among the formats for that specific source type which represents the data in the smallest number of bytes."
If an object can be represented in multiple possible output formats, serializers SHOULD use the format which represents the data in the smallest number of bytes.
Regarding the spec, I interpreted the following such that for "an object of a certain source type, serializers SHOULD use the format among the formats for that specific source type which represents the data in the smallest number of bytes."
If an object can be represented in multiple possible output formats, serializers SHOULD use the format which represents the data in the smallest number of bytes.
We don't assume certain source type.
If you want to enforce float packing, you can create PR for that.
I think that pack_fix_int64() is a good example:
Activity
redboltz commentedon Mar 23, 2024
It is intentional design. See #1070 and #1017.
We don't assume certain source type.
If you want to enforce float packing, you can create PR for that.
I think that
pack_fix_int64()is a good example:msgpack-c/include/msgpack/v1/pack.hpp
Lines 821 to 828 in e9e06a5
It always use MessagePack 64bit signed integer format even if the value is not require 64bit.
Similarlly, you can add
pack_fix_float()andpack_fix_double().When you would create the PR, please add tests too.
Test code locations are after
msgpack-c/test/msgpack_basic.cpp
Lines 148 to 200 in e9e06a5
and
msgpack-c/test/msgpack_basic.cpp
Lines 238 to 294 in e9e06a5