The 2's complement of a number is (10101100)2. What is that number, expressed…

2017

The 2's complement of a number is (10101100)2. What is that number, expressed in hexadecimal?

Answer: C. 0x54Concept — The 2's complement of an n-bit pattern is formed by inverting every bit and then adding 1; equivalently, it equals 2n minus the value of that…

  1. A.

    0x84

  2. B.

    0x24

  3. C.

    0x54

  4. D.

    0xAC

Attempted by 10 students.

Show answer & explanation

Correct answer: C

ConceptThe 2's complement of an n-bit pattern is formed by inverting every bit and then adding 1; equivalently, it equals 2n minus the value of that pattern. Because 2n − (2n − X) = X, the operation is its own inverse: applying it twice returns the original pattern. So if the 2's complement of some number is C, then that number is itself the 2's complement of C.

ApplicationHere C = 1010 1100, so the number is recovered by taking the 2's complement of C.

  1. Write the pattern given in the question: 1010 1100.

  2. Invert every bit to get the 1's complement: 0101 0011.

  3. Add 1: 0101 0011 + 1 = 0101 0100.

  4. Split the eight bits into two nibbles of four bits each: 0101 and 0100.

  5. Convert each nibble to one hexadecimal digit: 0101 = 5 and 0100 = 4, so the number is 0x54 (84 in decimal).

Cross-checkApply the operation once more to 0101 0100: inverting gives 1010 1011, and adding 1 gives 1010 1100, exactly the pattern stated in the question. As an independent check, a pattern and its 2's complement must sum to 28, and indeed 1010 1100 + 0101 0100 = 1 0000 0000 = 256.

Reading 1010 1100 the other way — as an 8-bit signed 2's-complement encoding rather than as the result of the operation — gives the value −84, whose magnitude 84 is again 0x54, so both readings agree on the same hexadecimal value.

ContrastExpanding each offered hexadecimal value into its 8-bit pattern makes the comparison direct:

Hexadecimal

8-bit pattern

Unsigned decimal

0x84

1000 0100

132

0x24

0010 0100

36

0x54

0101 0100

84

0xAC

1010 1100

172

Only 0101 0100 turns into 1010 1100 under bit inversion followed by adding 1; 1010 1100 is the pattern the question already supplies, left unconverted, while 1000 0100 and 0010 0100 produce 0111 1100 and 1101 1100 respectively. The number asked for is therefore 0x54.

Explore the full course: Cdac C Cat Complete Preparation

Loading lesson…