Arithmetic Right Shift
In an arithmetic right shift, each bit in a binary number is shifted to the right by a specified number of positions.
- The leftmost bit (the sign bit) is replicated to fill the vacated positions.
- If the number is positive, zeros are shifted in from the left.
- If the number is negative, ones are shifted in from the left.
Arithmetic right shifts are commonly used for division by powers of two in signed integer arithmetic.
Arithmetic Right Shift - Example
Original number: 1101 (decimal -3)
After arithmetic right shift by 1: 1110 (decimal -2)
Arithmetic right shift is a division operation that effectively divides the number by
for each shift.
Arithmetic Left Shift
In an arithmetic left shift, each bit in a binary number is shifted to the left by a specified number of positions.
- The leftmost bit is lost (shifted out)
- zeros are shifted in from the right.
Arithmetic left shifts are commonly used for multiplication by powers of two in signed integer arithmetic.
Arithmetic Left Shift - Example
Original number: 1101 (decimal -3)
After arithmetic left shift by 1: 1010 (decimal -6)
What is the purpose of an arithmetic left shift?
Interactive Demonstration
Arithmetic shifts are commonly used in programming languages to perform multiplication and division by powers of
.
Summary Example - 10001010 (Shift 1)
| Left Shift | Right Shift |
Logical |
00010100 | 01000101 |
Arithmetic | 11000101 |
Activity Complete