Programming languages often provide several operators to manipulate individual bits. Some common operators include:

  • &, |, ^, ~logical AND, OR, XOR, NOT
  • >>, <<shift right and left

Competitive programming

One notable structure is the bitset, which is an array that can only contain binary values. The benefit of this is that it saves on memory usage, since each element uses one bit of memory. In C++:

int struct_size = 10;
bitset<struct_size> s;

We can also operate on them more efficiently.