[1.2,1.3,1.4]
is 13 bytes, the equivalent binary storage is 3*sizeof(double) (24 bytes) + whatever overhead exists for representing a dynamic array in your language [1.2,1.3,1.4]
is 13 bytes, the equivalent binary storage is 3*sizeof(double) (24 bytes) + whatever overhead exists for representing a dynamic array in your languageOTOH this is pretty cherry picked. It is questionable if you really need floating point numbers if your numbers are all this small and low precision, but in actuality unless this comprises your entire message, you'll probably still lose to JSON overhead eventually anyways, whereas non-self-describing serialization like capnp has effectively no overhead by default. The advantage of encoding as doubles is that it is predictable and won't explode into taking massively more, its always the same size per number. If you want it to be smaller for some reason, compression is always an option, though I suspect for IPC it's the wrong thing to be concerned about.
Hexadecimal, if so. Nearly any decent modern language and runtime can it.
$ python
>>> import math
>>> math.pi.hex()
'0x1.921fb54442d18p+1'
This gives exact value without any rounding effects and conversion cost.(I donʼt count decimal floating-point as it is quite rare and its application is faint. In overwhelming most of cases, fixed point is better.)
Variable length binary number encodings are also an option.
The dynamic array overhead in a language is immaterial when discussion serialization formats.