Quote:Original post by TempHolder
Ok but can anyone give me a working example on how to reconstruct a float with 4 bytes?, because it isnt as easy as the interger when I tried it.
It is as easy as with an integer. A float is 4 bytes too. So instead of reading a float, you read an integer, then process it using s_p_oneil's code, then you use this little one-line inlined function:
inline float from_int(int i){ return *((float *)(&i));}
First, it takes the address of i and modify the type of the pointer to (float*). Then it dereference the pointed variable (which end up beeing a float).
This is not a cast from int to float, because the binary value don't change.
HTH,