Skip to content

Instantly share code, notes, and snippets.

@rhulha
Created January 26, 2017 07:51
Show Gist options
  • Select an option

  • Save rhulha/cff014effe5abed227ac878dcf2eb22b to your computer and use it in GitHub Desktop.

Select an option

Save rhulha/cff014effe5abed227ac878dcf2eb22b to your computer and use it in GitHub Desktop.
void printBitsI(unsigned int num)
{
for (int bit = 0; bit<(sizeof(unsigned int) * 8); bit++) {
printf("%i ", num & 0x01);
num = num >> 1;
}
}
void printBitsC(unsigned char num)
{
for (int bit = 0; bit<(sizeof(unsigned char) * 8); bit++) {
printf("%i ", num & 0x01);
num = num >> 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment