First remember that machine words are of fixed size. Say 4, and that your input is:
+---+---+---+---+
| a | b | c | d |
+---+---+---+---+
Then pushing everything one position to the left gives:
+---+---+---+---+
| b | c | d | X |
+---+---+---+---+
Question what to put as X?
- with a shift put 0
- with rotate put
a
Now push everything one position to the right gives:
+---+---+---+---+
| X | a | b | c |
+---+---+---+---+
Question what to put as X?
- with a logical shift put 0
- with an arithmetic shift put
a
- with rotate put
d
Roughly.
Logical shift correspond to (left-shift) multiplication by 2, (right-shift) integer division by 2.
Arithmetic shift is something related to 2's-complement representation of signed numbers. In this representation, the sign is the leftmost bit, then arithmetic shift preserves the sign (this is called sign extension).
Rotate has no ordinary mathematical meaning, and is almost an obsolete operation even in computers.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…