summaryrefslogtreecommitdiffstats
path: root/prime_mask.c
diff options
context:
space:
mode:
Diffstat (limited to 'prime_mask.c')
-rw-r--r--prime_mask.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/prime_mask.c b/prime_mask.c
new file mode 100644
index 0000000..d6b02d0
--- /dev/null
+++ b/prime_mask.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+#define LOW_BIT_ON 1 << 0
+#define FIRST_TWO_BITS_ON 3 << ((sizeof(unsigned int) * 8) - 2)
+
+int main(int argc, char **argv)
+{
+ /* seed rand() */
+ srand((unsigned int ) time(NULL));
+
+ unsigned int x = rand();
+ printf("x before masking: %10u 0x%08x\n", x, x);
+
+ x |= LOW_BIT_ON;
+ x |= FIRST_TWO_BITS_ON;
+
+ printf("x after masking : %10u 0x%08x\n", x, x);
+
+ return 0;
+}
+