Support for Long and Float specific number types #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Msgpack implementations on other platforms usually expect number formats to be in specific families like int and float. They do not do well when a value can be either int or float. Javascript's number type cannot be reliably pinned to be a float or an int, so tiny-msgpack (and msgpack-lite) make a best-guess effort to pick the right msgpack family.
This is not always acceptable for cross-platform message formats that use msgpack. This PR brings in support for specifying the number more specifically. One can encode a
Floatinstance and it will be encoded as float-32 or float-64, even if the value is an int, like 1.0.Similarly, if one has an int that is greater than 32 bits in length then you can now pass in a
Longinstance and see it encoded as either uint64 or int-64. This change adds a dependency on thelonglibrary, which is a pretty safe dependency.If you don't want to accept this PR, please let me know and I can release a new version of tiny-msgpack with these changes for my own purposes.