← 🔢 Number Systems & Binary Arithmetic
Subtopic 2 of 4

1.2Signed numbers: sign-magnitude, 1's and 2's complement

The idea

Signed numbers need a way to show the sign. Sign-magnitude uses a sign bit; 1's complement flips all bits; 2's complement flips all bits and adds 1 and is what real machines use.

Think of it like this: A clock face: going back one hour from 1 lands on 12, so −1 is simply the pattern just below 0.

Why it exists

Range, the number of zeros and negation are asked as one or two mark questions almost every few years.

How it works

  1. n-bit 2's complement range is −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1; sign-magnitude and 1's complement run from −(2ⁿ⁻¹ − 1) to +(2ⁿ⁻¹ − 1).
  2. Sign-magnitude and 1's complement both have +0 and −0; 2's complement has one zero.
  3. To negate in 2's complement, invert all the bits and add 1.
  4. The MSB of a 2's complement number has weight −2ⁿ⁻¹.

Worked example: −5 in 4 bits

Sign-magnitude 1101; 1's complement: invert 0101 → 1010; 2's complement: 1010 + 1 = 1011. Check: −8 + 2 + 1 = −5.

Now play with it

  • →Set the decimal to −8 with 4 bits: only 2's complement can hold it.
  • →Look at the table: which pattern 1000 means different things in each column?
Sign-magnitude1101
1's complement1010
2's complement1011
Range (sign-mag, 1's)−7 … +7
Range (2's)−8 … +7
Distinct values (sm, 1's)15
Distinct values (2's)16
patternunsignedsign-mag1's compl.2's compl.
00000000
00011111
00102222
00113333
01004444
01015555
01106666
01117777
10008−0-7-8
10019-1-6-7
101010-2-5-6
101111-3-4-5
110012-4-3-4
110113-5-2-3
111014-6-1-2
111115-7−0-1

Both sign-magnitude and 1's complement have two zeros (+0 and −0). 2's complement has one zero and one extra negative number (−2ⁿ⁻¹), which has no positive partner.

Check yourself

The range of an 8-bit 2's complement number is

Remember: Only 2's complement has a single zero and an extra negative number.
Exam notes (the dense version)

With n bits: sign-magnitude and 1's complement cover −(2ⁿ⁻¹ − 1) … +(2ⁿ⁻¹ − 1) and both have two zeros. 2's complement covers −2ⁿ⁻¹ … +(2ⁿ⁻¹ − 1) with a single zero, so there is one extra negative number. To negate in 2's complement: invert all bits and add 1 (or copy bits up to and including the first 1 from the right, invert the rest). Sign-extend by copying the MSB. The weight of the MSB is −2ⁿ⁻¹.

Previous year questions: Number Systems & Binary Arithmetic (5)

PYQs are grouped by topic, so this is the full set for Number Systems & Binary Arithmetic; try the ones that match this subtopic. Open all 5 on the topic page.