Converting 2's complement to decimal

  • Thread starter Thread starter dangish
  • Start date Start date
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
2 replies · 17K views
dangish
Messages
72
Reaction score
0
Convert the binary number 11001100 from 8-bit 2’s complement notation to decimal. Remember to specify the sign of the decimal number.

attampt: because the MSB is 1, the number is negative, therefore invert all the numbers getting:

00110011

now convert that to decimal which is, 2^0 + 2^1 + 2^4 + 2^5 = 51

then add 1, 51+1 = 52

and make that negative getting -52. Is this correct?
 
Physics news on Phys.org
dangish said:
Convert the binary number 11001100 from 8-bit 2’s complement notation to decimal. Remember to specify the sign of the decimal number.

attampt: because the MSB is 1, the number is negative, therefore invert all the numbers getting:

00110011

now convert that to decimal which is, 2^0 + 2^1 + 2^4 + 2^5 = 51

then add 1, 51+1 = 52

and make that negative getting -52. Is this correct?
Yes, although I would invert the binary bits and add 1 then, which gives you 00110100.

The check is that 11001100 + 00110100 == 00000000, and in fact, it is. (There's a final 1 bit, but it's out too far to fit in 8 bits.)
 
Since you know its 2's complement and therefore the first number is a negative, can't you just add the bits like normal?

-128 + 64 + 0 + 0 + 8 + 4 + 0 + 0 = -52