Skip to content

Instantly share code, notes, and snippets.

@wilhelmtell
Created May 5, 2010 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilhelmtell/390388 to your computer and use it in GitHub Desktop.
Save wilhelmtell/390388 to your computer and use it in GitHub Desktop.
#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