A bit shift is a bitwise operation where the order of several 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 (central processing unit) 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.
For 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.