Is my 2's complement addition correct?

  • Thread starter Thread starter TranscendArcu
  • Start date Start date
  • Tags Tags
    Addition
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 3K views
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
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.
[tex]A = f(B) = b_02^0 +b_12^1 +b_22^2 + ... + b_{n-1}2^{n-1} -b_n2^n[/tex]
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.