msgpack-php icon indicating copy to clipboard operation
msgpack-php copied to clipboard

Allow forcing floats to be encoded as F32

Open jackprice opened this issue 11 months ago • 2 comments

This merge allows users to force floats to be encoded as 32-bit floats (float 32) rather than the default 64-bit doubles. This would primarily be useful for reducing the storage size of the packed result, and has no effect on unpacking, aside from the loss in precision that will happen transparently.

If there is appetite for this and this fits with style/structure expected I will expand to allow similarly forcing int8,int16 etc.

I've implemented this as an option on the packer class, but also as an ini flag (though I'm unsure if that's actually useful).

jackprice avatar Feb 19 '25 21:02 jackprice

👍 LGTM; test cases are a bit suspicious; anything better to do there?

m6w6 avatar Feb 19 '25 21:02 m6w6

👍 LGTM; test cases are a bit suspicious; anything better to do there?

Awesome, thanks! I just basically mirrored some existing tests, what would you prefer?

jackprice avatar Feb 19 '25 22:02 jackprice