Reputation: 19
I need to compress floating point numbers (4 bytes) to 1 byte(0 to 0xFF) to send to another device. The floating point numbers range from -100000.0 to 100000.0.
The other device will decode from 1 byte back to floating point numbers. How do it do it with minimum data loss?
Thanks, JC
Upvotes: 1
Views: 1565
Reputation: 705
One solution is to use quantization. Divide 100000 to 127 intervals. Send the interval number to which float belongs to and a sign in lowest or highest bit
In your case the interval = 787,4 For example, you have input like 100. Send 1. Input 1000,147732. Send 2 On the device you can restore number by its interval. The easiest solution is to restore the number as a middle of the interval. For example, every float that belongs to the first interval will be restored as 393.7 If you have some stats for digits distribution and it's not uniform, you can play around it by changing the intervals length and quantize frequent floats more precisely
Upvotes: 2