2
$\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
  • 2
    $\begingroup$ The 2's compliment representation of -100 is 1001 1100 and not 1110 0100 $\endgroup$ Commented Oct 16, 2014 at 8:07
  • $\begingroup$ @ParthThakkar You are right, I misunderstood the question, so silly of me! $\endgroup$ Commented Oct 16, 2014 at 8:11

1 Answer 1

5
$\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$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.