Skip to content

Instantly share code, notes, and snippets.

@carlosgaldino
Created November 3, 2015 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosgaldino/5ec9363db358cbc2ec18 to your computer and use it in GitHub Desktop.
Save carlosgaldino/5ec9363db358cbc2ec18 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int bit_and(int x, int y)
{
return ~(~x | ~y);
}
int main(int argc, char **argv)
{
printf("%.8x\n", bit_and(6, 5));
printf("%.8x\n", bit_and(8, 1));
printf("%.8x\n", bit_and(8, 10));
printf("%.8x\n", bit_and(9, 7));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment