Is my 2's complement addition correct?

  • Thread starter Thread starter TranscendArcu
  • Start date Start date
  • Tags Tags
    Addition
AI Thread Summary
The discussion focuses on verifying the correctness of two's complement addition in 8-bit binary. The first addition, 01110110 + 10001001, is calculated as -1, while the second, 11010101 + 10101010, results in -171. Participants point out that the original poster is miscalculating the decimal conversions and not applying the two's complement method correctly. It is emphasized that two's complement addition should treat the numbers as unsigned binaries and ignore carries beyond the most significant bit. The conversation highlights the importance of understanding the two's complement representation for accurate binary arithmetic.
TranscendArcu
Messages
277
Reaction score
0
Do the following additions in 8-bit binary two's complement:

a) 01110110 + 10001001 = (64+32+16+4+2) + (-(64+32+16+4+2+1)) = 118 -119 = -1
b) 11010101 + 10101010 = -(64+16+4+1) + (-(64+16+4+1+1)) = -86 -87 = -171

Have I done these correctly?
 
Physics news on Phys.org
You do understand that converting to base 10 combining adding those is NOT "twos complement" don't you?

What is the "twos complement" of 10001001.
 
TranscendArcu said:
Do the following additions in 8-bit binary two's complement:

a) 01110110 + 10001001 = (64+32+16+4+2) + (-(64+32+16+4+2+1)) = 118 -119 = -1
b) 11010101 + 10101010 = -(64+16+4+1) + (-(64+16+4+1+1)) = -86 -87 = -171

Have I done these correctly?

For starters, you're not even converting the numbers to decimal correctly.
A = f(B) = b_02^0 +b_12^1 +b_22^2 + ... + b_{n-1}2^{n-1} -b_n2^n
where A is the base 10 representation, B is a binary 2's complement representation of a number with n+1 digits with b_0 being the least significant digit. Note that only the last digit has a minus sign.
 
For two's complement addition in binary, you just add the two numbers as if they were unsigned binary numbers (ignoring any carries past the most significant bit), to get the sum. I don't know if this assignment requires that you indicate if signed overflow has occurred.
 
I picked up this problem from the Schaum's series book titled "College Mathematics" by Ayres/Schmidt. It is a solved problem in the book. But what surprised me was that the solution to this problem was given in one line without any explanation. I could, therefore, not understand how the given one-line solution was reached. The one-line solution in the book says: The equation is ##x \cos{\omega} +y \sin{\omega} - 5 = 0##, ##\omega## being the parameter. From my side, the only thing I could...
Back
Top