Skip to content
BetterDL

Arithmetic shift right

Also called: ASR, SRA, arithmetic right shift, signed shift right, sign-preserving shift

A right shift that copies the old sign bit into the MSB. For a two's complement number it divides by 2, keeping the sign and rounding down.

An arithmetic shift right moves every bit one place toward the LSB, but instead of a 0 it puts a copy of the old sign bit into the MSB. The sign bit ends up duplicated.

Why: in two's complement, a negative number has MSB = 1. Shifting in a 0 (a logical shift right) would make it positive. Copying the sign bit keeps the sign and makes the shift divide by 2 correctly. It is the same idea as sign extension.

  • 1100 (−4) → 1110 (−2) → 1111 (−1).
  • 0110 (+6) → 0011 (+3). For positive numbers it matches a logical shift.

Rounding: the dropped bit is discarded, so the result rounds down, toward −∞, not toward zero. For negative odd numbers this differs from what decimal division might suggest: −5 → −3, and −1 stays −1. See rounding toward negative infinity.

In hardware: a shift-right register with its serial input wired to its own MSB. At the edge, Q3 reloads its old value while Q2 copies it too. A universal shift register in mode 01 with SIR wired to Q3 does exactly this.

There is no separate "arithmetic shift left": shifting left with 0 entering on the right already multiplies a two's complement number by 2, as long as it does not overflow.

1
−128
1
64
1
32
0
16
1
8
1
4
0
2
0
1

Worked examples

Example

Halving −20

The register above holds 11101100, which is −20 in 8-bit two's complement. Apply one arithmetic shift right.

  1. 1.

    The sign bit is 1, so a 1 enters on the left.

  2. 2.

    Every bit moves right; the last 0 drops off: 11110110.

  3. 3.

    11110110 = −128 + 64 + 32 + 16 + 4 + 2 = −10. ✓

Example

Rounding a negative odd number

An 8-bit register holds −9, 11110111. Apply one arithmetic shift right.

  1. 1.

    Copy the sign bit in: 11111011.

  2. 2.

    11111011 = −128 + 64 + 32 + 16 + 8 + 2 + 1 = −5.

  3. 3.

    −9 ÷ 2 = −4.5, which rounds down to −5, not toward zero to −4.

Common mistakes

  • Shifting in a 0 for a negative number. That is a logical shift and gives a large positive result.

  • Expecting rounding toward zero. Arithmetic shift right rounds toward −∞.

  • Thinking −1 shifts to 0. 1111 shifted arithmetically is still 1111, which is −1.

Practice Arithmetic shift right

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Arithmetic shift right is taught in Registers and Adders and ALUs.