Created
May 5, 2010 04:49
-
-
Save wilhelmtell/390388 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
union ufloat { | |
float f; | |
char b[sizeof(float)]; | |
}; | |
int main(int argc, char* argv[]) | |
{ | |
ufloat u1 = { 3.75f }; | |
for( int i = 0; i != sizeof(float); ++i ) { | |
for( int j = 0x80; j != 0; j >>=1 ) { | |
cout << ((u1.b[i] & j) != 0); | |
} | |
cout << ' '; | |
} | |
cout << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment