Machine-translated by Google. Questions are authored in English.
Top

Discussion

Let R1 and R2 be two 4-bit registers that store numbers in 2's complement form. For the operation R1+R2, which one of the following values of R1 and R2 gives an arithmetic overflow?

  • A.R1 = 1011 and R2 = 1110
  • B.R1 = 1100 and R2 = 1010
  • C.R1 = 0011 and R2 = 0100
  • D.R1 = 1001 and R2 = 1111

Answer: B

Overflow occurs for R1 = 1100 and R2 = 1010.

In 4-bit two's complement the range is −8 to 7. Overflow happens when two numbers of the same sign give a result outside that range, which shows as a result with the opposite sign.

1100 is −4 and 1010 is −6. Their sum is −10, below −8; the 4-bit result is 0110, a positive number, so the addition overflows.

The others stay in range: 1011 + 1110 is −5 + (−2) = −7; 0011 + 0100 is 3 + 4 = 7; 1001 + 1111 is −7 + (−1) = −8, the most negative value, still representable.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.