-
Notifications
You must be signed in to change notification settings - Fork 321
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
Single-precision doubles always written at FLOAT64 instead of FLOAT32 #489
Comments
@mattbishop It's because msgpack's specification of Float Value type: Value objects are implementation of MessagePack types systems, and it's a bit different MessagePack's format types, which have FLOAT32/64. |
The Float Value type decides how to encode itself into the msgpack stream, and the spec allows for either single-precision or double-precision float values in the encoded result. The single precision is shorter, and thus preferrable, when no data loss will occur.
My request with this issue is to consider packing a double as Float32 when it will correctly encode the value, and thus save space. Msgpack is about saving bytes on the wire, after all. |
@mattbishop I understand what you need. For clarity, msgpack has two specs for formats (with FLOAT32/64) and types (only FLOAT64).
If we check float -> DoubleValue(double) -> float has no precision loss as you showed, it would be OK as long as DoubleValue.doubleValue() are correctly used in user applications. If some application assumes getting FLOAT64 msgpack type from DoubleValue, it will fail with this change. |
A single-precision decimal value should be written as a smaller FLOAT32 instead of always using FLOAT64. A simple test for single-precision can be added to
ImmutableDoubleValueImpl
:The text was updated successfully, but these errors were encountered: