msgpack-lite icon indicating copy to clipboard operation
msgpack-lite copied to clipboard

encoding number types should not use both Int and Float families

Open mattbishop opened this issue 7 years ago • 0 comments

When msgpack-lite encodes a number primitive type, the actual encoded value will be either in the Int family or the Float family. While the msgpack spec does allow for serializing to the smallest-possible type in a given family, it doesn't allow for crossing over to another family. See https://github.com/msgpack/msgpack/blob/master/spec.md#serialization-type-to-format-conversion

Given that JS has no way to clarify int vs float values, I would like to see the addition of a Float class to msgpack so that a developer could explicitly state a number is in fact a float, event if the value itself can be interpreted as an int.

As a bonus, it would be nice to accept a Long value as well so that one does not have to manually pass in Int-64 objects.

The addition of these two class types would give developers control over the family used to encode their values. The existing number support can stay for backwards compatibility.

mattbishop avatar Oct 13 '18 17:10 mattbishop