Is my 2's complement addition correct?

  • Thread starter Thread starter TranscendArcu
  • Start date Start date
  • Tags Tags
    Addition
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
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
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.
[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.