Skip to content

Instantly share code, notes, and snippets.

@felipewer
Created August 29, 2016 14:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save felipewer/e7d67f2993006532f99e5d66f76c92ff to your computer and use it in GitHub Desktop.
Save felipewer/e7d67f2993006532f99e5d66f76c92ff to your computer and use it in GitHub Desktop.
Print bits of unsigned char
// 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));
}
@trickre
Copy link

trickre commented Jan 13, 2017

very compact!simple! thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment