Created
March 23, 2016 18:59
-
-
Save tuxmartin/426ff7dbe201519a3aa8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
#define COUNT 5 | |
int main(void) { | |
int mask = 0; | |
for (int j = 0; j < 32; j++) { | |
printf("mask[%02d] = ", mask); | |
for (int i = 0; i < COUNT; i++) { | |
if(((mask >> i) & 0x01)) { | |
printf("1 "); | |
} else { | |
printf("0 "); | |
} | |
} | |
mask++; | |
printf("\n"); | |
} | |
} | |
/* | |
$ gcc -o mask mask.c && ./mask | |
mask[00] = 0 0 0 0 0 | |
mask[01] = 1 0 0 0 0 | |
mask[02] = 0 1 0 0 0 | |
mask[03] = 1 1 0 0 0 | |
mask[04] = 0 0 1 0 0 | |
mask[05] = 1 0 1 0 0 | |
mask[06] = 0 1 1 0 0 | |
mask[07] = 1 1 1 0 0 | |
mask[08] = 0 0 0 1 0 | |
mask[09] = 1 0 0 1 0 | |
mask[10] = 0 1 0 1 0 | |
mask[11] = 1 1 0 1 0 | |
mask[12] = 0 0 1 1 0 | |
mask[13] = 1 0 1 1 0 | |
mask[14] = 0 1 1 1 0 | |
mask[15] = 1 1 1 1 0 | |
mask[16] = 0 0 0 0 1 | |
mask[17] = 1 0 0 0 1 | |
mask[18] = 0 1 0 0 1 | |
mask[19] = 1 1 0 0 1 | |
mask[20] = 0 0 1 0 1 | |
mask[21] = 1 0 1 0 1 | |
mask[22] = 0 1 1 0 1 | |
mask[23] = 1 1 1 0 1 | |
mask[24] = 0 0 0 1 1 | |
mask[25] = 1 0 0 1 1 | |
mask[26] = 0 1 0 1 1 | |
mask[27] = 1 1 0 1 1 | |
mask[28] = 0 0 1 1 1 | |
mask[29] = 1 0 1 1 1 | |
mask[30] = 0 1 1 1 1 | |
mask[31] = 1 1 1 1 1 | |
martin@martin:~/mask$ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment