Created
July 6, 2018 11:46
-
-
Save BrunoVandekerkhove/04b490549bba92ccbc710a8166e6c130 to your computer and use it in GitHub Desktop.
Print bits of an unsigned integer (reversed order)
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
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