See also:
IEEE 754 single-precision binary floating-point format: binary32
float convert16to32float(unsigned int Xi_Value)
{
//TODO:test, imporve, optimize..
int exp = (Xi_Value>>10) & 0x01f;
float g=0;
unsigned int *i=(unsigned int *) & g;
Xi_Value &= 0xffff;
*i=0;
*i |= Xi_Value << 16 & 0x80000000; //sign
*i |= (exp-15+127) << 23; //exponent
*i |= (Xi_Value & 0x3FF) << 13; //value
return g;
}
Advertisement
Tags: bits, floatingpont