Skip to content

Instantly share code, notes, and snippets.

@pierrejoye
Created October 8, 2013 13:41
Show Gist options
  • Save pierrejoye/6884858 to your computer and use it in GitHub Desktop.
Save pierrejoye/6884858 to your computer and use it in GitHub Desktop.
#define flag1 1<<0
#define flag2 1<<1
#define flag3 1<<2
#define flag4 1<<3
long arg1 = flag1|flag2;
long arg2 = flag1|flag4;
printf("%i %i %i %i \n", flag1, flag2, flag3, flag4);
printf("%i %i %i %i \n", flag1|flag2, flag1|flag4);
if (arg1 & (flag1)) {
printf("b1 set\n");
}
if (arg1 & (flag2)) {
printf("b2 set\n");
}
if (arg1 & (flag3)) {
printf("b3 set\n");
}
if (arg1 & (flag4)) {
printf("b4 set\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment