Skip to content
BetterDL

Rounding toward negative infinity

Also called: round toward negative infinity, floor rounding, rounding down, round down, floor division by shifting

Right shifts drop the bits that fall off, so the result is rounded down to the next lower integer: 7 shifts to 3, and −7 shifts to −4, not −3.

When a register is shifted right, the bits that fall off the end are simply thrown away. The effect on the value is rounding down, toward −∞ (also called the floor).

For non-negative numbers, rounding down and rounding toward zero agree:

  • 7 → 3 (7 ÷ 2 = 3.5, rounded down).
  • 13 → 6.

For negative numbers they differ. An arithmetic shift right rounds toward −∞, so negative odd numbers go further from zero:

  • −7 → −4, not −3 (−3.5 rounded down).
  • −5 → −3, not −2.
  • −1 → −1, not 0. Shifting 1111 arithmetically gives 1111 again.

Why: in two's complement, discarding the low bits always subtracts their (non-negative) contribution, so the value can only move down.

This matters in practice. Many programming languages define integer division as rounding toward zero, so a compiler cannot always replace x / 2 by an arithmetic shift for signed x; it adds a correction for negative values first.

The safe method: do the shift on the bits, then decode the result. Don't guess it from decimal division.

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

Worked examples

Example

Shifting −7 (the value above)

11111001 is −7 in 8-bit two's complement. Apply one arithmetic shift right.

  1. 1.

    Copy the sign bit in on the left: 11111100.

  2. 2.

    Decode: −128 + 64 + 32 + 16 + 8 + 4 = −4.

  3. 3.

    −7 ÷ 2 = −3.5, and rounding toward −∞ gives −4. ✓

Example

Unsigned values round down too

A 4-bit unsigned register holds 0111 (7). Shift it right logically.

  1. 1.

    Result: 0011 = 3.

  2. 2.

    The dropped bit was 1, the remainder of 7 ÷ 2.

  3. 3.

    3.5 rounded down is 3, the same as rounding toward zero for a positive number.

Common mistakes

  • Assuming a right shift rounds toward zero. That is only true for non-negative values.

  • Predicting the answer from decimal division instead of shifting the bits.

  • Expecting −1 to shift to 0. It stays −1.

Practice Rounding toward negative infinity

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

Learn it step by step

Rounding toward negative infinity is taught in Registers and Number Systems.