Skip to main content

Division of signed integers

Short answer

Use sign-magnitude division: divide absolute values, then set quotient sign to XOR of operand signs and remainder sign to dividend sign. For -15 divided by 4, magnitude division gives quotient 3 and remainder 3, so the result is quotient -3, remainder -3.

How can division of signed integers be performed? Explain with example.

Division of signed integers is done on the magnitudes (sign-magnitude method), and the signs are handled separately:

  1. Store the sign of the dividend (Sd) and of the divisor (Sv); take the absolute values.
  2. Divide the magnitudes with the restoring or non-restoring algorithm to get quotient Q and remainder R.
  3. Quotient sign = Sd XOR Sv (negative if the signs differ).
  4. Remainder sign = sign of the dividend, so that dividend = divisor × quotient + remainder.
  5. If the dividend and divisor are in 2's complement, convert negative values to positive before step 2 and convert the results back at the end.
  6. Check for divide overflow: the divisor must not be 0 and the quotient must fit in the register.

Example: −15 ÷ 4 (4-bit magnitudes)

  • Sd = 1, Sv = 0, so quotient sign = 1 XOR 0 = 1 (negative); remainder sign = 1 (negative).
  • Divide the magnitudes 15 ÷ 4 with restoring division:
Step  Action                  A      Q
-     Initial                 00000  1111
1     Shift left A,Q          00001  1110
      A = A - M (1 - 4 = -3)  11101  1110
      A<0: Q0=0, restore A    00001  1110
2     Shift left A,Q          00011  1100
      A = A - M (3 - 4 = -1)  11111  1100
      A<0: Q0=0, restore A    00011  1100
3     Shift left A,Q          00111  1000
      A = A - M (7 - 4 = 3)   00011  1000
      A>=0: Q0=1              00011  1001
4     Shift left A,Q          00111  0010
      A = A - M (7 - 4 = 3)   00011  0010
      A>=0: Q0=1              00011  0011

Magnitude result: quotient 3, remainder 3.

Answer: −15 ÷ 4 = quotient −3, remainder −3, because 4 × (−3) + (−3) = −15.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Organization and Architecture chapter 5 questions →