Skip to content

Instantly share code, notes, and snippets.

@cacharle
Created November 19, 2019 23:32
Show Gist options
  • Save cacharle/af891127545e3907057d277120511b58 to your computer and use it in GitHub Desktop.
Save cacharle/af891127545e3907057d277120511b58 to your computer and use it in GitHub Desktop.
#define PRINT_BYTE(x) (print_bits((x), 8))
#define PRINT_WORD(x) (print_bits((x), 16))
#define PRINT_DWORD(x) (print_bits((x), 32))
#define PRINT_QWORD(x) (print_bits((x), 64))
void print_bits(unsigned long long int n, int s)
{
if (s == 0)
return;
print_bits(n >> 1, s - 1);
printf("%d", n & 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment