Adding 8 bit 2's complement numbers.

In summary, the conversation discusses the process of performing arithmetic operations using eight-bit 2's complement numbers and determining if an arithmetic overflow occurs. The participants discuss the steps of inverting the second term, adding it to the original form, adding 1, and then adding it to the first term. They also mention that 2's complement has a property where the result remains the same, but there may be a "kind of overflow." They clarify that this is not considered an "arithmetic overflow."
  • #1
shamieh
539
0
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
 
Technology news on Phys.org
  • #2
shamieh said:
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.
 

FAQ: Adding 8 bit 2's complement numbers.

1. What is a 2's complement number in 8 bit format?

A 2's complement number is a way of representing signed numbers in binary format. In 8 bit format, it can hold values from -128 to 127, with 0 as the midpoint.

2. How do I add 8 bit 2's complement numbers?

To add 8 bit 2's complement numbers, you can use the same method as adding regular binary numbers. Start from the rightmost bit and add the digits, carrying over the 1 if the sum is greater than 1. If there is a carry out of the leftmost bit, this indicates overflow and the result is invalid.

3. What is the purpose of using 2's complement in adding numbers?

2's complement is used to represent negative numbers in binary format. It simplifies the process of addition and subtraction, as well as enables the use of logical operations on signed numbers.

4. What happens if I try to add two 8 bit numbers and the result exceeds the range of 2's complement?

If the result of adding two 8 bit 2's complement numbers exceeds the range, this indicates overflow and the result is invalid. This can happen if the sum of two positive numbers is a negative number, or if the sum of two negative numbers is a positive number.

5. Can I add 8 bit 2's complement numbers with different bit lengths?

Yes, you can add 8 bit 2's complement numbers with different bit lengths. However, it is important to keep track of the sign bit and properly extend the shorter number to match the bit length of the longer number before performing the addition.

Back
Top