Shift

In digital electronics, to shift is to move all the bits of a register to the left (left shift) or right (right shift). The last bit in the shift direction is "shifted out", while a new bit is supplied for the first.
Example:

The shift operation of a microprocessor is an amazingly useful function which generally takes very few cycles to complete, often as few as one. It can be used for (among many other things) multiplication and division by two (to a point.) Using this feature repeatedly can also multiply and divide by powers of two through repetition.

Let us look at the base 10 number "1" as represented in one byte of binary:

Shifting right (towards the LSB or least significant bit) will of course divide by two. The only problem becomes when you shift a bit into the bit bucket. You can solve this problem by shifting with carry on some architectures, and then look at the carry bit to determine if you have overflowed the register. If you have done so on a shift right, then your result is the result plus 0.5. If you have done so on a shift left, then the result is the result plus 256 in the case of eight bits, or 2 raised to the number of bits in the register in all cases.

There are other forms of the shift instructions present on some architectures. I will use the x86instruction set by way of example. x86 includes SAL (shift arithmetic left) and SAR (shift arithmetic right) instructions. SHL (shift left) and SAL do the same thing; for each step, each bit is shifted left one place (from LSB towards MSB) and a 0 is brought into the LSB. However, SAR does something differently; The value of the MSB is preserved, thus preserving the sign of signed integers.

The shift function is related to the rotate operations, which instead of losing the MSB or LSB, move the ordinarily lost bit into its antithesis. Hence a rotate right (ROR) will shift all bits toward the LSB, and move the LSB into the MSB.

The first typewriter, built in 1868, only typed in capital letters. The second-generation model, in 1878, allowed UPPERCASE and lowercase letters. The trick was that each typebar (the piece that would swing up and hit the page with the letter) now had an Uppercase and lowercase letter on it. Pressing the "Shift" key would actually shift the typebars in order to shift the Uppercase keys into position.

Of course, the modern typewriters and word processors and electronic devices no longer need to shift mechanically, but the name stuck, and carried over to computer use, as the QWERTY keyboard layout was used to mimic a conventional typewriter.