Adding & Subtracting Binary numbers

Thread Starter

Shamieh

Joined Oct 24, 2013
36
A little confused on this problem... Suppose I have

000111
+ 111101
_________

wouldn't I just have

7 - 61 = -68

Thus my answer would be: 1000100 ? But wouldn't I have an overflow? & if i Had an overflow and discarded that 1 then wouldn;t I have the incorrect answer? OR do I need to take the second number and invert it and then add 1? But wouldn't doing that change the number all together?
 

Thread Starter

Shamieh

Joined Oct 24, 2013
36
Well it says to perform the following 6-bits 2's complement addition, note whether an overflow occurs, and if there isnt a overflow write down the result in decimal.
 

Thread Starter

Shamieh

Joined Oct 24, 2013
36
Here are the directions. Perform the following 6-bit 2's complement addition, note whether an overflow occurs, and if there isn't an overflow write down the result in decimal.

000111
+
111101
_______

I'm assuming this is 7 + -61 = -68

And I got 1000100 but I got 7 digits so I got a extra number so wouldn't that be an overflow?

Or would I need to take that second number and 2's complement it making it 000010 + 1 getting 000011 and then take that new number and have 000111 + 000011 getting 001010?

 

MrChips

Joined Oct 2, 2009
19,928
2's complement means that both positive and negative numbers are represented, i.e. 6-bit signed integers.

Your two numbers are 6 bits long.

The first number is 7. The second number is -3.
7 + (-3) = 4
 

shteii01

Joined Feb 19, 2010
4,647
Here are the directions. Perform the following 6-bit 2's complement addition, note whether an overflow occurs, and if there isn't an overflow write down the result in decimal.

000111
+
111101
_______

I'm assuming this is 7 + -61 = -68

If 111101 is in 2's complement form, then it is not -61.

If I am reading right, you have some number X. You want to perform operation: 7-X. To do this you need to rewrite the operation: 7+ (-X). The -X is given to you, it is 111101. But we don't know what the original X was in the first place. And because we don't know the original X, we can not check your answer.

It looks like X originally was 3. So what you are trying to do is: 7-3

To get -3 you take 3 and do 2's complement on it, you get 111101, so now you have -3.

Now we do 7+ (-3): 000111 + 111101, we get overflow and a 4. Since 7-3=4, we did the math correctly, but the overflow causes the answer to be out of bound since the highest value for 6 bit number is 64, but we got 64+4=68.
 

Thread Starter

Shamieh

Joined Oct 24, 2013
36
Yes, but if we have 7 - 4 = 3, then we disregard the 1 right? So we wouldn't have an overflow correct? because its 7 +- 3 = 4 which is just 000100 which = 3. So don't we just disregard the one?
 

WBahn

Joined Mar 31, 2012
25,107
A little confused on this problem... Suppose I have

000111
+ 111101
_________

wouldn't I just have

7 - 61 = -68

Thus my answer would be: 1000100 ? But wouldn't I have an overflow? & if i Had an overflow and discarded that 1 then wouldn;t I have the incorrect answer? OR do I need to take the second number and invert it and then add 1? But wouldn't doing that change the number all together?
Signed binary representations only make sense for fixed-width representations because we need to have a known location for the sign bit. So if you are using a six bit representation, you will end up with a six bit result.

How are you getting that 111101 is -61? How would you represent +61?

The following material might help you out:

http://www.dragonwins.com/domains/getteched/binary/index.htm
 
Top