Representing a float in a single byte

Viewed 7989

I have a situation which requires a float to be represented in a single char. The range that this 'minifloat' needs to represent is 0 to 10e-7, so we can always assume that the number is +ve, and the exponent -ve in order to save space.

The representation that I have thought about going with is 3 bits of exponent, and 5 bits mantissa (with 1 implied bit), with the exponent being in base 10, i.e. x = man * 10^exp.

To convert from a float to my minifloat, I plan to use frexp, and use some maths to convert from base 2 to base 10.

Is this a sensible approach? Or are there better ways to achieve this?

4 Answers
Related