Bit flags, Bit masks and why they are useful? Explanation with examples.First of all we want to know what bit flag is and what is bit mask, in this post I would like to give brief knowledge on bit flags and bit masks
Bit Flags: As of we know that we cannot access bits directly, So we have to use the bit-wise operators to set, unset, or query them.
Bit flags are the individual bits that are used to improve the efficiency of the storage.
In storage-intensive cases where we have lots of related Boolean options, it can be useful to “pack” 8 individual Boolean's into a single byte for storage efficiency purposes.
Why are bit flags useful?
Bit flags are used in two cases:
1) It is very much useful when you have many sets of identical bit flags.