Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding number types should not use both Int and Float families #96

Open
mattbishop opened this issue Oct 13, 2018 · 0 comments
Open

Comments

@mattbishop
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant