In computer science, a mask is data that is used for bitwise operations, particularly in a bit field. Using a mask, multiple bits in a byte, nibble, word etc .. can be set either on, off or inverted from on to off (or vice versa) in a single bitwise operation.
== Common bitmask functions ==
=== Masking bits to 1 ===
To turn certain bits on, the bitwise OR operation can be used, following the principle that Y OR 1 = 1 and Y OR 0 = Y. Therefore, to make sure a bit is on, OR can be used with a 1. To leave a bit unchanged, OR is used with a 0.
Example: Masking on the higher nibble (bits 4, ...