Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for a half float or quarter float library [closed]

I need to store values in a range of about -10000 to 10000. At the range borders, the precision needed is not very high (maybe about 64, I will see how it fits), around zero the precision needs to be 1 or better.

Unfortunately space is very limited, not more than 12 bits, less would even be better. So strictly speaking, even half floats are out. Is there an open source library which handles some very short float formats with short mantissa and exponent length? Like 8 bit mantissa and 3 bit exponent.

Only conversion from/to bigger formats is required, no arithmetic is done.

like image 939
Gunther Piez Avatar asked Mar 15 '12 13:03

Gunther Piez


2 Answers

If you're not doing any computation, then there's barely a need for a library. frexp, ldexp and some bit-twiddling should do the job.

like image 109
Oliver Charlesworth Avatar answered Sep 29 '22 00:09

Oliver Charlesworth


Perhaps μ-law or A-law could be useful for you.

like image 39
Jens Björnhager Avatar answered Sep 29 '22 00:09

Jens Björnhager