Skip to content

Instantly share code, notes, and snippets.

@BrunoVandekerkhove
Created July 6, 2018 11:46
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 BrunoVandekerkhove/04b490549bba92ccbc710a8166e6c130 to your computer and use it in GitHub Desktop.
Save BrunoVandekerkhove/04b490549bba92ccbc710a8166e6c130 to your computer and use it in GitHub Desktop.
Print bits of an unsigned integer (reversed order)
void print_bits(unsigned int num) {
for (int bit=0 ; bit<(sizeof(unsigned int) * 8) ; bit++, num = num >> 1)
printf("%i ", num & 0x01);
printf("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment