I need to comvert 1 float into 4 bytes and then back to 1 float again. Someone told me to try this:
FLOAT f1 = 123.456, f2 = 0.0 ;
BYTE byByte1 = HIBYTE( HIWORD( f1 ) ) ;
BYTE byByte2 = LOBYTE( HIWORD( f1 ) ) ;
BYTE byByte3 = HIBYTE( LOWORD( f1 ) ) ;
BYTE byByte4 = LOBYTE( LOWORD( f1 ) ) ;
f2 = byByte1 << 24 | byByte2 << 16 | byByte3 << 8 | byByte4 ;
The rebuild answer for this is f2 = 123.000 and not 123.456. How can a get the rest of my float? What am I doing wrong? Also what is required to break down to bytes, a double (8bytes) and rebuild the 8 bytes into one double? All sugestions welcome and sample code is greatly appreciated!