[1][2] A bit field is most commonly used to represent integral types of known, fixed bit-width, such as single-bit Booleans.
[3] Within CPUs and other logic devices, collections of bit fields called flags are commonly used to control or to indicate the outcome of particular operations.
[2] Bit fields can be used to reduce memory consumption when a program requires a number of integer variables which always will have low values.
Having a number of these tiny variables share a bit field allows efficient packaging of data in the memory.
In this case, the programmer can declare a structure for a bit field which labels and determines the width of several subfields.
Additionally, branching instructions are also defined to alter execution based on the current state of a flag.
A large number of languages support the shift operator (<<) where 1 << n aligns a single bit to the nth position.
To check the nth bit from a variable v, perform either of the following: (both are equivalent) Writing, reading or toggling bits in flags can be done only using the OR, AND and NOT operations – operations which can be performed quickly in the processor.