Add CBORGenerat.Feature.WRITE_MINIMAL_DOUBLES for writing doubles as floats if safe to do so by here-abarany · Pull Request #356 · FasterXML/jackson-dataformats-binary (original) (raw)

Enabling WRITE_MINIMAL_DOUBLES works similarly to WRITE_MINIMAL_INTS, choosing to use a smaller data representation (single-precision float) when the conversion will result in no loss of data. This can provide a substantial savings for data that contains many doubles that don't require full precision.

Cleaned up some of the writing code for floats and doubles to avoid code duplication, and reserve the proper amount of space for output for both types.