MHB Adding 8 bit 2's complement numbers.

  • Thread starter Thread starter shamieh
  • Start date Start date
  • Tags Tags
    Bit Numbers
AI Thread Summary
The discussion revolves around performing arithmetic operations with eight-bit 2's complement numbers and understanding overflow. The initial problem involves adding the numbers 01110101 and 11011110, where the second number is recognized as negative due to its leading bit. The confusion arises from the steps taken to handle the negative number, including inverting it and adding 1, which is unnecessary for direct addition in 2's complement. The correct approach is simply to add the two numbers directly. The outcome indicates a type of overflow, but it does not constitute arithmetic overflow since the result remains within the valid range of 2's complement representation. Arithmetic overflow specifically occurs when two positive numbers yield a negative result, which is not the case here.
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.
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top