I'm looking for a way to optimize float32
value, that contains only values from (0, 1)
for wireless transfer.
Since in my case all values are positive, I've already trimmed Sign bit, but now I need some help
I think, that my next step is going to be trimming all Fraction trailing zeroes zeros, and then, somehow optimize Exponent part
But I'm not quite sure, maybe there is already some bit-level optimizations exists for same cases, since using float32
to store values between (0, 1)
is very common practice
Data integrity and error correction are not relevant in my case
So, I've decided to just use uint16_t
, where 0=0f
and 65365=1f
, which is enough for me. But at memory level I'm not actually using float at all. This integer-based logic helped me not only achieve shorter byte sequence for wireless transfer, but also use less memory
Other option is to use uint32_t
, that will use the same amount amount of bits
Conversion to float, if you need it, is smth like this:
float to_float = (float) value / (float) UINT16_MAX