kawanet / msgpack-lite

Fast Pure JavaScript MessagePack Encoder and Decoder / msgpack.org[JavaScript]
https://www.npmjs.com/package/msgpack-lite
MIT License
991 stars 129 forks source link

32 bit floating point #94

Open bQvle opened 6 years ago

bQvle commented 6 years ago

Is it possible to encode as 32 bit floating points instead of 64?

I'm sending a lot of floating number over a socket and this seems quiet expensive.

1.1 = [203, 63, 241, 153, 153, 153, 153, 153, 154]

mattbishop commented 6 years ago

This is actually correct behaviour because 1.1 is a double-precision float value, which is 64 bits. You can see in the Node REPL:

> Math.fround(1.1)
1.100000023841858
thatcort commented 5 years ago

I'd also like to be able to force 32-bit float encoding. Is this possible?