1
$\begingroup$

There is an 8-bit numerical value, where a negative number is represented in two’s complement. When this value is represented in decimal, it becomes -100. When this value is regarded as an unsigned number, which of the following is the correct value in decimal?

First, I have to calculate the decimal 100 in binary, and add the signed bit at the start :

1110 0100

Then, to get the non-negative decimal value of the object, I convert the two complement back to its original value :

0001 1100

which gives me the result is 28

But the correct answer is 156, this is the value I will get if I did not replace the MSB (1) with (0) when converting the two complement back to the original value

1001 1100

What am I missing here?

$\endgroup$
  • 2
    $\begingroup$ The 2's compliment representation of -100 is 1001 1100 and not 1110 0100 $\endgroup$ – Parth Thakkar Oct 16 '14 at 8:07
  • $\begingroup$ @ParthThakkar You are right, I misunderstood the question, so silly of me! $\endgroup$ – f855a864 Oct 16 '14 at 8:11
4
$\begingroup$

First consider the decimal number 100. Binary notation of 100 would be

01100100

Applying the two's complement, we find that -100 must be

10011011 + 00000001 = 10011100

Assuming now this is unsigned, we get $128+16+8+4=156$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.