Adding 8 bit 2's complement numbers.

  • Context: MHB 
  • Thread starter Thread starter shamieh
  • Start date Start date
  • Tags Tags
    Bit Numbers
Click For Summary
SUMMARY

The discussion focuses on adding eight-bit 2's complement numbers, specifically the operation of 01110101 + 11011110. The correct approach is to directly add the two numbers without inverting the second term, as 2's complement allows for straightforward addition. The result of the addition is 11111111, which indicates that there is no arithmetic overflow, as overflow occurs only when adding two positive numbers results in a negative number. The final answer of 01010110 is incorrect; the correct interpretation of the result is crucial for understanding 2's complement arithmetic.

PREREQUISITES
  • Understanding of 2's complement representation
  • Basic knowledge of binary addition
  • Familiarity with overflow concepts in arithmetic
  • Ability to interpret binary numbers
NEXT STEPS
  • Study the properties of 2's complement arithmetic
  • Learn about binary addition techniques
  • Research conditions for arithmetic overflow in binary operations
  • Explore examples of 2's complement operations with different bit lengths
USEFUL FOR

Students and professionals in computer science, software engineers working with low-level programming, and anyone interested in digital systems and binary arithmetic.

shamieh
Messages
538
Reaction score
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

$$
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
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

$$
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.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
4K
Replies
1
Views
3K
Replies
5
Views
2K
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 17 ·
Replies
17
Views
2K
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
9K
Replies
3
Views
12K
  • · Replies 1 ·
Replies
1
Views
3K