# Adding two signed 2 Bit number?

Discussion in 'Homework Help' started by Hamed4U, Feb 25, 2011.

1. ### Hamed4U Thread Starter New Member

Feb 25, 2011
6
0
I want to add two signed 2 bit number?
How can I do it?
I know know do I need 2 bit for output or 3 bit?

Nov 25, 2009
5,151
1,266
3. ### Hamed4U Thread Starter New Member

Feb 25, 2011
6
0
Thanks
Look I have problem with these
10 (Is -2 in 2-bit signed number)
11 (Is -1)
01 ( Is +1)
00 (Is 0)

After add 00 + 10 = 010 (or 10)
It is positive number not a negative number!??

Also 10 + 10 = 100 and 10+11 =100 (-1-2=-3??) ?? How to show them?

Is it possible to have result in two bit? or I should have three bit?

4. ### Georacer Moderator

Nov 25, 2009
5,151
1,266
10 is not -2. It is -0, in the signed number representation.
Can you tell us what are the operations you want to do in the decimal system? Are you sure you want to use the signed number representation for your operations, instead of, say, 2's complement?

5. ### Hamed4U Thread Starter New Member

Feb 25, 2011
6
0
I want to add two Signed 2-bit number.
like 00 + 10 = ? 10+10 =? 00+ 00=? 11+11=? 10+11=????? and .....
Operation is + (Sum) of two Signed 2-bit number.
I don't know who to show trust table and after that design circuit!

I know 2's complement, K-Map,Binary Operation.

6. ### Georacer Moderator

Nov 25, 2009
5,151
1,266
Unfortunately, in signed numbers (not complemented) you have to do the subtraction manually, as in the decimal system. I 'll talk about 4-bit numbers to be more general.

For example: two positive numbers - 5+4
_0101
+0100
-------
_1001

Of course, there is an overflow and that must be taken into account.

One negative number: 3-7
In that case you must do the subtraction disregarding the signs, adding them after the end of the operation.
_1__
_111
-011
-------
_100

Since you know that the result will be negative, you add the sign to the result: 1100.

As for the operations you ask about, they are
00+10=00 or 10
10+10=00 or 10
00+00=00 or 10
11+11=110
10+11=11

You see that with signed numbers, the method of operation is identical to our decimal addition and subtraction, only with a different base.

This is why 2's complement simplifies those operations a lot, removing the need to distinguish between addition and subtraction, positive and negative numbers.

7. ### Hamed4U Thread Starter New Member

Feb 25, 2011
6
0
Then I need 3-bit for output?
can help me to fill out trust table:
Code ( (Unknown Language)):
1.
2. A1  A0    B1   B0     C  S1  S0
3.  0   0     0    0     0   0   0
4.  0   0     0    1     0   0   1
5.  0   0     1    0     0   1   0
6.  0   0     1    1     0   1   1
7.  0   1     0    0     0   0   1
8.  0   1     0    1     0   1   0
9.  0   1     1    0     0   1   1
10.  0   1     1    1     1   0   0
11.  1   0     0    0     0   1   0
12.  1   0     0    1     0   1   1
13.  1   0     1    0     1   0   0
14.  1   0     1    1     1   0   1
15.  1   1     0    0     0   1   1
16.  1   1     0    1     1   0   0
17.  1   1     1    0     1   0   1
18.  1   1     1    1     1   1   0
19.

Last edited by a moderator: Feb 26, 2011
8. ### Georacer Moderator

Nov 25, 2009
5,151
1,266
It is called a truth table.

Since you will represent the result with 3 bits, you must use a fixed position for the sign. I would suggest that you use C to hold the sign and S1 to be the carry, as now your result is a 3-bit number, with the sign on the MSB.

That said, you have the following mistakes:
00+00 (0+0)=X00
00+10 (0-0)=X00
01+10 (1-0)=001
01+11 (1-1)=X00
10+00 (-1+1)=X00
10+01 (-0+1)=001
10+10 (-0-0)=X00
11+00 (-1+0)=101
11+01 (-1+1)=X00

I think that was all of them.

9. ### Hamed4U Thread Starter New Member

Feb 25, 2011
6
0
11 + 11 (-1-1) ??
00 + 01 (0+1) = 001 ?
10+00 (-1+1)=X00 Should Change to (0+0)??

Can I use two bit for result?

10. ### Georacer Moderator

Nov 25, 2009
5,151
1,266
You can't use only 2 bits to represent the result, since you have results for other combinations that require 3 bits to be represented. Follow one template at a time.

11+11=110 (-2)
00+01=001 as you correctly said.
10+00 (-0+0)=X00 ($\pm$00)

X means that either 1 or 0 is a correct answer, and it facilitates the simplification through a Karnaugh map.

10 isn't -1 and 00 isn't +1, as you wrote in your third line. You seem to make many mistakes when converting numbers from one system to the other. I suggest making a strong revision from your class textbook.

11. ### Hamed4U Thread Starter New Member

Feb 25, 2011
6
0
Then output should be 3 bit.
1st bit is sign bit
If 1st bit was 1 we have negative number and we need to find 2's complement to know value?
00 + 10 why not 010 ?

12. ### Georacer Moderator

Nov 25, 2009
5,151
1,266
2's complement hasn't been introduced in this exercise. We haven't used it anywhere, and we won't.
In signed numbers, as you said, the 1st bit is the sign. The magnitude is the rest of the bits "as is", in a pure binary representation. For example, 111 is -3.

00+10=X00. Think about it. 00 is +0. 10 is -0. The result is 0, independently of its sign. And remember that the sign goes in the first bit. 010 is +2, so it's not the correct answer.