Computer Science

Two Complement

Find the two’s complement representation of a negative integer.

Two’s Complement = Invert all bits + 1

Formula Explanation

For a fixed bit width, invert the bits of the positive representation and add one.

Variables Explained

Bit width = Number of bits used to represent the integer.

Solved Example

Find the 8-bit two’s complement of +5 as a representation of -5.
00000101 → 11111010 → 11111011. Therefore -5 = 11111011 in 8-bit two’s complement.

Exam Tip

Use the required bit width throughout the conversion.