A bit shift is a bitwise operation where the order of a series of bits is moved, either to the left or right, to efficiently perform a mathematical operation. Bit shifts help with optimization in low-level programming because they require fewer calculations for the CPU than conventional math. Bit shifting operations may be declared explicitly by the programmer, or automatically by the compiler if it can identify that such an optimization is possible.
As an example, consider the integer 23, represented with eight bits:
If we shift all the bits left one place, discard the leftmost bit, and insert a zero on the right, the result is the binary representation of 46:
This action is effectively the same as multiplying the number by two.