Frage

I know the answer is 29 but I'm not sure how to arrive at it.

Usually I would take 011101 get its inverse of 100010 and add 1 to get 100011.

The value of this is 35. How then is the answer 29?

War es hilfreich?

Lösung

011101 is 29  //Binary to Decimal
100011 + 011101 = 000000  //100011 is inverse+1
100011 = -011101  
100011 = -29

There is no '35' because in a two's compliment system any number starting with a '1' is a negative number. This means, assuming 6 bits, that any number greater than 31 (011111) is in fact a negative number.

Andere Tipps

The term "two's complement" is ambiguous.

  • 011101 is the two's complement representation of the decimal number 29.
  • Performing the two's complement operation on 011101 results in 100011 (decimal -29, since two's complement notation uses the most-significant-bit as the sign bit).

The answer is 35, not 29.

invert(0b011101) + 0b1 = 0b100010 + 0b1 = 0b100011 = 35

The question was for the two's complement of 29:

0b011101 = 29

The "inverse +1" procedure is for encoding negative numbers.

You know this number is positive because the high bit is zero, so:

1*2^4 + 1*2^3 + 1*2^2 + 0*2^1 + 1*2^0 = 16 + 8 + 4 + 0 + 1 = 29

100011 is correct, and its decimal equivalent is indeed 35. How do you know it should be 29?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top