edited by
21,487 views
35 35 votes

The addition of $4-bit$, two's complement, binary numbers $1101$ and $0100$ results in

  1. $0001$ and an overflow
  2. $1001$ and no overflow
  3. $0001$ and no overflow
  4. $1001$ and an overflow

5 Answers

Best answer
73 73 votes

Answer: C.

The addition results in $0001$ and no overflow with $1$ as carry bit.

In 2's complement addition Overflow happens only when:

  • Sign bit of two input numbers is $0$, and the result has sign bit $1$.
  • Sign bit of two input numbers is $1$, and the result has sign bit $0$.
edited by
4 4 votes

Key Concepts

  1. Unsigned Numbers:

    • These are simply positive numbers (no sign) in binary. For example, 0100 in unsigned binary is just 4.
  2. Signed Numbers:

    • These represent both positive and negative numbers. The most common way to represent signed numbers is two's complement.
  3. Two's Complement:

    • This is the most widely used system for representing signed binary numbers. In two's complement:
      • Positive numbers are the same as their unsigned binary representation.
      • Negative numbers are obtained by inverting the bits of the number and adding 1.
      • The Most Significant Bit (MSB) indicates the sign of the number. If the MSB is 1, the number is negative; if the MSB is 0, the number is positive.

    Important Note: In two's complement, when you add two numbers, the result will automatically handle the sign of the number, as long as you have the right number of bits.

  4. One's Complement:

    • This is similar to two's complement, but instead of adding 1 after inverting the bits, you just invert the bits. One's complement is less commonly used than two's complement.

------------------------------------------------------------------------------------------- 

  • 1101: In 4-bit two's complement, the MSB is 1, so it's negative.

    • To find the decimal value:
      1. Invert the bits: 1101 becomes 0010.
      2. Add 1: 0010 + 1 = 0011 (which is 3 in decimal).
      3. Since the MSB was 1, the value is -3.
  • 0100: In 4-bit two's complement, the MSB is 0, so it’s positive.

    • 0100 in binary is simply +4 in decimal.
 

Adding the Two Numbers

We now add the two numbers:

1101(−3)+0100(+4)

 = 10001(Carry 1 out)​​

 

Here, the result is 10001. Since we’re working with 4-bit numbers, we ignore the extra carry bit on the left (because we’re adding two 4-bit numbers, the result should fit in 5 bits).

So, the final result is 0001, which equals +1 in decimal.

 Why Do We Ignore the Extra Bit?

In binary addition, if the result has more bits than the original number of bits, you simply ignore the carry. This is why we ignore the extra leftmost bit, and the final result is 0001 (which is +1).

This process happens because, in two's complement, the range of values for a 4-bit number is -8 to +7. If you get a result that exceeds this range (like a 5th bit), it means the value overflows. But in this case, the overflow bit indicates a carry, and it’s ignored.

 

Extra Info :  Two's Complement Interpretation (for Negative Numbers)

When interpreting a two's complement number, you check the MSB:

  • If the MSB is 0, the number is positive.
  • If the MSB is 1, the number is negative, and you need to invert the bits and add 1 to get the positive equivalent.

For example:

  • 111: The MSB is 1, so it's negative. Inverting the bits: 000. Adding 1 gives 001, which is 1. So, 111 represents -1.
  • 011: The MSB is 0, so it's positive. 011 is just +3 in decimal.

Can You Directly Add/Subtract Two's Complement Numbers?

Yes, you can directly add or subtract two's complement numbers. The beauty of two's complement is that it allows you to perform addition and subtraction without worrying about whether the numbers are positive or negative. The result will automatically be correct, including handling overflow and the sign of the number.

 

 

Summary : 

  • Two's complement allows you to handle negative numbers using the MSB.
  • For addition, just add the numbers like normal binary addition and ignore any overflow beyond the original bit width (4-bits, 8-bits, etc.).
  • Conversion between positive and negative numbers is handled by inverting the bits and adding 1 for negative numbers.
  • The MSB (most significant bit) tells you whether the number is positive or negative:
    • 0 means positive.
    • 1 means negative (and you need to take the two's complement to find its magnitude).
1 1 vote

when ever positive and negative no is added it may cause over flow

0 0 votes

1101 in decimal form is -3
0100 in decimal form is 4
(-3+4)=1 which is 0001 in binary.

The range of an n-bit number in 2's complement form is:


since 1 is in the given range -8 to 7, it would not be an overflow.so, answer is C.

1 flag:
✌ Edit necessary (Kshitij_Rabadey)
–3 –3 votes
2's complement of 1101 is 0011

2,s complement of 0100 is 1100

now we add 0011 nd 1100 gives 1111

so it doesnot give any extra bit in carry so no overflow nd convert 1111 in original form of no 0001

so (c) option is correct
Answer:
Position:
Show:

Related questions

74 74 votes
4 answers 4 answers
23.2k
23.2k views
Ishrat Jahan asked Oct 31, 2014
23,246 views
Which of the following statements about relative addressing mode is FALSE?It enables reduced instruction sizeIt allows indexing of array element with same instructionIt e...
32 32 votes
3 answers 3 answers
15.2k
15.2k views
gatecse asked Sep 21, 2014
15,211 views
Let $f(x)$ be the continuous probability density function of a random variable $x$, the probability that $a < x \leq b$, is :$f(b-a)$$f(b) - f(a)$$\int\limits_a^b f(x) dx...
40 40 votes
9 answers 9 answers
14.4k
14.4k views
Kathleen asked Sep 22, 2014
14,396 views
The range of integers that can be represented by an $n$ bit $2’s$ complement number system is:$-2^{n-1} \text{ to } (2^{n-1} -1)$$-(2^{n-1} -1) \text{ to } (2^{n-1} -1)$$...
17 17 votes
2 answers 2 answers
9.8k
9.8k views
Rucha Shelke asked Sep 26, 2014
9,751 views
Consider the following code written in a pass-by-reference language like FORTRAN and these statements about the code. subroutine swap(ix,iy) it = ix L1 : ix = iy L2 : iy ...