Number System

Two’s Complement

Students flip reversible cards and add one counter at the end.

Two’s Complement definition

Two’s complement is a fixed-width binary representation that can encode positive, zero, and negative integers.

In Spanish
complemento a dos
Topic
Numeral systems and bases

Two’s Complement in a picture

Two’s Complement diagramThe four-bit pattern 1101 has value −8 + 4 + 1 = −3.Four-bit word: 1101Weights: −8, 4, 2, 1−8 + 4 + 0 + 1Add the occupied weightsResult: −3With unsigned weights it would mean 13
The four-bit pattern 1101 has value −8 + 4 + 1 = −3.

How it works

In an n-bit word, the highest bit has weight −2ⁿ⁻¹, while the other bits use ordinary positive weights. An n-bit word represents values from −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1. To negate a representable value within the width, flip every bit and add one, discarding a carry beyond the width. The most negative value has no positive counterpart within the same width.

Worked examples

Decode 1111 in four-bit two’s complement.

−8 + 4 + 2 + 1 = −1.

Encode −3 using four bits.

Start from 0011, invert to 1100, and add 1 to get 1101.

What is the signed range for four bits?

−8 to 7.

Common mistake

State the bit width and interpretation. The same pattern can give different values with unsigned and signed weights.

Quick check

What is the weight of the top bit in a four-bit word?

Show answer

−8.

What is four-bit two’s complement 1000?

Can +8 fit in four-bit two’s complement?

Show answer

No. The largest value is 7.

Sources

Flashcard

Two’s Complement

Reveal the definition

Two’s complement is a fixed-width binary representation that can encode positive, zero, and negative integers.

Effortless Math. “Two’s Complement.” Math Dictionary.