Welcome to our community

Be a part of something great, join today!

Adding 8 bit 2's complement numbers.

shamieh

Active member
Sep 13, 2013
539
I don't understand something.

Perform the following operations involving eight-bit 2's complement numbers and indicate whether arithmetic overflow occurs.

If I have

\(\displaystyle
01110101
+11011110
\)

I know that the second term is negative because there is a 1 in front.

Now, because it is negative do I need to

1) Take the second term and invert it making it: 00100001.

2) then do I need to add the original form of it.. so: 11011110 + 00100001 = 11111111

3) Then add 1 to it? 11111111 + 1 = 11111110

4)Then go back to my original problem and put

01110101 + The new number? --> 111111110

and I know that if I have two positive numbers (both most left bit begins with zero, then I won't have overflow). But how will I know if I have overflow with these numbers?

Will my final answer be... 01010110 ? It doesn't make sense I follwoed this guys steps exactly and It just doesn't work
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,774
I don't understand something.

Perform the following operations involving eight-bit 2's complement numbers and indicate whether arithmetic overflow occurs.

If I have

\(\displaystyle
01110101
+11011110
\)

I know that the second term is negative because there is a 1 in front.

Now, because it is negative do I need to

1) Take the second term and invert it making it: 00100001.

2) then do I need to add the original form of it.. so: 11011110 + 00100001 = 11111111

3) Then add 1 to it? 11111111 + 1 = 11111110

4)Then go back to my original problem and put

01110101 + The new number? --> 111111110

and I know that if I have two positive numbers (both most left bit begins with zero, then I won't have overflow). But how will I know if I have overflow with these numbers?

Will my final answer be... 01010110 ? It doesn't make sense I follwoed this guys steps exactly and It just doesn't work
You're supposed to just add them.
It's a property of 2's complement that the result comes out the same, which makes 2's complement so useful.

As you can see, you get a kind of overflow.
This overflow is supposed to happen and it yields the correct answer.
This is not an "arithmetic overflow", since that indicates that the magnitude of the result is too large to fit, which is not the case.

You would get an arithmetic overflow if you add two positive numbers, and the result comes out as a negative number.