Mask

Updated: 05/21/2018 by Computer Hope

Illustration of a bitmask.In reference to computers, a mask is a special value that acts as a data filter. It's called a "mask" because it reveals some parts of digital information, and conceals or alters others.

Bitmasks

In binary operations, a bitmask can be used to filter bit values using logical operations. For instance, a bitmask of 00001111, when used with the boolean AND operation, will always convert the first four bits of another byte (the other operand) to 0. The final four bits will be unchanged. This is called "masking out" the first four bits, changing them to 0.

If the OR operator is used, any 1 bit values in the bitmask will produce a 1 in the corresponding bit of the result, and the other bits remain unchanged. So, a bitmask of 00001111, used with OR, will "mask out" the last four bits, changing them to 1.

If the XOR operator is used, any 1s in the bitmask cause corresponding bits in the operand to be toggled1 becomes 0, and 0 becomes 1.

Bitmask examples
Bitmask 00001111 00001111 00001111 00001111
Operation AND AND OR XOR
Operand 11010010 01101101 10010110 01011010
Result 00000010 00001101 10011111 01010101

Netmask

A netmask is another type of bitmask, used in computer networking. One type of netmask, a subnet mask, defines logical divisions ("subnets") of a computer network. For instance, a subnet mask of 255.255.255.0 masks out the first three bytes of an IP address, leaving only the final byte — the host identifier.

Search masks

In Microsoft Windows, a search mask is a string, which may contain wildcards, which filters search results. It's commonly used to search for files by name. For instance, in the command:

forfiles /m "s*.exe"

The search mask s*.exe is used by the forfiles command to locate all .exe files in the current directory whose name begins with s.

Umask

In Unix-like operating systems such as Linux, BSD, and macOS X, a umask is a mask of octal values which sets the permissions of new files created on the system.

For information about user file creation masks in Linux, see umask in our Linux command guide.

Filter, Software terms