I have a float number stored in 1 byte( as floatin point in 8 bits). Do we have a library function in boost or c++11 (or 14), which would convert the floating point number into decimal fraction?
I know how to convert the 8 bits( sign bit, exponent, mantissa) into decimal fraction. I just wanted to make use of library function instead of writing a new one ?
Referencing an existing function also would be helpful
The standard approach would not be very efficient, but exists:
Of course, this is cheating by using the built-in floating point serialization code. But that seems to be precisely what you are asking for.
For fun, I put together a very limited fixed-point type. Note the constructor is very flawed (it doesn't know (de)normal, NaN, and doesn't scale small mantissa's well at all). But it does demonstrate the conversions above enough so I could check they worked right:
Live On Coliru
Prints