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
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:
publicvoidwriteTo(MessagePackerpk) throwsIOException {
// ValueFactory always writes a float64; needs to be a float32 for single-precisionif (toDouble() == toFloat()) {
pk.packFloat(toFloat());
} else {
pk.packDouble(toDouble());
}
}
The text was updated successfully, but these errors were encountered:
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).
(Double)Value is an implementation of msgpack types, so we need to follow the spec, that is, representing DoubleValues as double-precision values inside Value objects.
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: