First of all, bitmasks are for operating on bits, not integers. It is much easier to understand when we deal with just 1's and 0's than more complex numbers.
So for example:
1000110000010000100001000 = 18358536 // in binary.
0000010000000000000000000 = 524288 // in binary.
0000000000000000000001000 = 8 // in binary.
0000010000000000000001000 = 524296 // in binary.
With this, it is clear that integer 8 is a 4th bit from the right side and no other bits marked, so when we add 8 to 524288 (20th bit only) we are simply marking 4th and 20th bits as being true. So we can use the same space in memory reserved for an integer to hold multiple flags that define some boolean properties.
As Alex already explained, you can then check if any flag is available in bitmask by using bitwise AND operator:
if ((mask & flag) == flag) { /* mask has flag set as true */ }
You can read everything about bitmasks in this article