Hi!
Trying to read all the bits in a float and write them to a string by doing something like:
for( unsigned int Iterator = 0; Iterator < 32; Iterator++ ) {
if( ( unsigned int )FromFloat & ( unsigned int )0x80000000 )
ToString[ Iterator ] = '1';
else ToString[ Iterator ] = '0';
( unsigned int )FromFloat <<= 1;
}
The actual problem is this: error C2106: '<<=' : left operand must be l-value. Now I can't even begin to see why the compiler doesn't think it can write to "( unsigned int )FromFloat". And skipping the type casting is even worse as it seems bitwise operations are illegal on floats.
TIA!
, Espen

Bitwise << and floats
Giorgio Sardo
Why not using a bitset
leonreet
In my opinion you should consider the following approach too:
I hope after adjustments it will be suitable for you. Your original attempt actually seems to work with truncated values.
DanInNewWest
Thanx for your help. Modifying a very small part of my code after reading your example worked perfectly:
float Float = 1346.98f;
unsigned int _Float = ( unsigned int & )Float;
And then using _Float throughout the code worked.
, Espen