A lossy compressor might also be useful for common floating point apps. The simplest compressor ever would just chop off a number of bits from the mantissa.
That code is absolutely terrible! Never do that. The range is awful, and the relative error is awful.
If you want a double in 32 bits, convert to single precision float. This will beat the relative error of the code you linked to by orders of magnitude, and allow the range of float (~1e38) rather than be limited to +- 1e9.
https://x.com/Densebit/status/1839705674378613043?s=20