Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <stdio.h>
#include <stdlib.h>
typedef union {
unsigned int i;
float f;
} holder;
void printBits(int x)
{
int i;
unsigned int mask = 1 << 31;
for (i = 0; i < 32; i++) {
if (x & mask) {
printf("1");
}
else {
printf("0");
}
mask >>= 1;
}
printf("\n");
}
int main(void)
{
holder h;
h.f = 3.14;
printBits(h.i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment