All subjects · Computer Science · WCP01 Principles of Computer Science
Two's complement: representing signed integers
Edexcel IAL Computer Science · WCP01 Principles of Computer Science
Two's complement lets a fixed number of bits hold negative as well as positive whole numbers, and lets the same adder do subtraction (spec point 2.1.3).
How it works
In two's complement the most significant bit (MSB) has a negative place value. For 8 bits the place values are:
-128, 64, 32, 16, 8, 4, 2, 1
- If the MSB is 0 the number is positive (or zero), read as normal.
- If the MSB is 1 the number is negative: -128 plus the other place values.
- Range for n bits: -2n-1 to 2n-1 - 1. For 8 bits: -128 to 127.
Example: 1101 0100 = -128 + 64 + 16 + 4 = -44.
Negating a number
To change the sign of a two's complement number (either way):
1. Invert every bit (0 to 1, 1 to 0).
2. Add 1.
Shortcut: copy bits from the right up to and including the first 1, then invert the rest.
Example: 44 = 0010 1100. Invert: 1101 0011. Add 1: 1101 0100 = -44.
Why it is needed
- Computers must store negative numbers using only 0s and 1s.
- There is only one zero (unlike sign and magnitude, which has +0 and -0).
- Subtraction can be done by adding the negative, so the ALU needs only an adder.
- Drawback: the range is fixed by the number of bits, and the MSB is used for the sign, so the largest positive value is roughly halved compared with unsigned.
Worked example
Convert -75 to 8-bit two's complement.
- 75 = 0100 1011
- Invert: 1011 0100
- Add 1: 1011 0101
- Check: -128 + 53 = -75
Answer: 1011 0101
Check yourself
- What is the denary value of the 8-bit two's complement number 1010 0110?
Show answer
-90. -128 + 38 = -90.
- What is the denary value of the 8-bit two's complement number 0101 0011?
Show answer
83. The MSB is 0, so read as normal: 64 + 16 + 2 + 1 = 83.
- Convert -20 to 8-bit two's complement.
Show answer
11101100. 20 = 0001 0100; invert to 1110 1011; add 1 gives 1110 1100.
- Convert -1 to 8-bit two's complement.
Show answer
11111111. 1 = 00000001; invert to 11111110; add 1 gives 11111111.
- What is the most negative number that 8-bit two's complement can represent?
Show answer
-128. 10000000 = -128.
- What is the largest positive number that 12-bit two's complement can represent?
Show answer
2047. 211 - 1 = 2047.
- The 8-bit two's complement pattern 1101 1011 is negated. What is the denary value of the result?
Show answer
37. 1101 1011 = -37; negating gives +37 (0010 0101).
- Why is two's complement preferred to sign and magnitude?
- It can represent larger positive numbers with the same bits
- It has only one representation of zero and subtraction can be done by addition
- It does not need an MSB
- It stores fractions exactly
Show answer
It has only one representation of zero and subtraction can be done by addition. One zero, and the same adder works for subtraction.
Sources
- Pearson Edexcel International Advanced Subsidiary/Advanced Level in Computer Science specification (2026)
- Pearson Edexcel IAL Computer Science IAS sample assessment materials (Unit 1, WCP01)
Last updated 8 November 2026. Spotted a mistake? Tell us.