Created
August 29, 2016 14:26
-
-
Save felipewer/e7d67f2993006532f99e5d66f76c92ff to your computer and use it in GitHub Desktop.
Print bits of unsigned char
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
// Obtained from http://stackoverflow.com/a/700184 | |
void printbits(unsigned char v) { | |
int i; // for C89 compatability | |
for(i = 7; i >= 0; i--) putchar('0' + ((v >> i) & 1)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very compact!simple! thanks.