summaryrefslogtreecommitdiffstats
path: root/prime_mask.c
blob: d6b02d07c009355213b914d9492c66b60af4c2d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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;
}