Representing Negative Numbers
So far, every binary number you have worked with has been unsigned — it can only represent zero or positive values. But computers need negative numbers too. Think about bank balances, temperatures below zero, or game characters moving backwards. How can a system that only has 0s and 1s represent something like −42?
The answer is two’s complement. It is the most widely used method for representing signed (positive and negative) integers in modern computers. Nearly every processor in every phone, laptop, and server uses two’s complement, and it is a core topic in your GCSE Computer Science exam.
The idea is elegant: in an 8-bit two’s complement number, the leftmost bit (the Most Significant Bit, or MSB) acts as a sign bit:
- If the MSB is 0, the number is positive (or zero).
- If the MSB is 1, the number is negative.
With 8 bits, two’s complement can represent any integer from −128 to +127. That is 256 different values in total — the same count as unsigned 8-bit binary (0 to 255), but the range is shifted to include negative numbers.
How Two’s Complement Works
The Modified Place Value Table
In unsigned binary, the place values for 8 bits are:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|
In two’s complement, the only change is that the MSB becomes negative:
| −128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|
That single change is all it takes. The rest of the place values stay exactly the same. To read a two’s complement number, you simply add up the place values of every column that has a 1 in it — just as you always do with binary — but remember that the leftmost column is now −128.
Reading Two’s Complement Numbers
Example 1: What is 11111011 in two’s complement?
Place values: -128 64 32 16 8 4 2 1
Bits: 1 1 1 1 1 0 1 1
Calculation: -128 + 64 + 32 + 16 + 8 + 0 + 2 + 1
= -128 + 123
= -5
The answer is −5. Notice that the MSB contributes −128, and all the other 1-bits add up to +123, giving a final value of −5.
More examples:
10000000 = -128 + 0 = -128 (most negative 8-bit value)
01111111 = 0 + 64+32+16+8+4+2+1 = +127 (most positive 8-bit value)
11110000 = -128 + 64+32+16 = -16
11111111 = -128 + 64+32+16+8+4+2+1 = -1
00000000 = 0 = 0
Converting Positive to Negative: The 3-Step Method
To convert a positive number to its negative two’s complement representation, follow these three steps:
- Step 1: Write the positive number in 8-bit binary.
- Step 2: Flip all the bits (change every 0 to 1 and every 1 to 0). This is called the one’s complement.
- Step 3: Add 1 to the result.
Worked Example 1: Represent −5 in two’s complement.
Step 1: Write +5 in binary: 0 0 0 0 0 1 0 1
Step 2: Flip all bits: 1 1 1 1 1 0 1 0 (one's complement)
Step 3: Add 1: 1 1 1 1 1 0 1 1 (two's complement)
-5 in two's complement = 11111011
Worked Example 2: Represent −20 in two’s complement.
Step 1: Write +20 in binary: 0 0 0 1 0 1 0 0
Step 2: Flip all bits: 1 1 1 0 1 0 1 1 (one's complement)
Step 3: Add 1: 1 1 1 0 1 1 0 0 (two's complement)
-20 in two's complement = 11101100
Worked Example 3: Represent −1 in two’s complement.
Step 1: Write +1 in binary: 0 0 0 0 0 0 0 1
Step 2: Flip all bits: 1 1 1 1 1 1 1 0 (one's complement)
Step 3: Add 1: 1 1 1 1 1 1 1 1 (two's complement)
-1 in two's complement = 11111111
This is a famous result: −1 is always represented as all 1s in two’s complement, regardless of how many bits you use.
Key Properties
Range of Two’s Complement
The range depends on the number of bits used. For n bits, the range is −2n−1 to +2n−1 − 1.
| Number of Bits | Minimum Value | Maximum Value | Total Values |
|---|---|---|---|
| 8-bit | −128 | +127 | 256 |
| 16-bit | −32,768 | +32,767 | 65,536 |
| 32-bit | −2,147,483,648 | +2,147,483,647 | 4,294,967,296 |
Notice that there is always one more negative number than there are positive numbers. For 8-bit, you can reach −128 but only +127. This asymmetry exists because zero takes up one of the “positive” slots (00000000).
Zero in Two’s Complement
Zero is simply 00000000. There is only one representation of zero in two’s complement — this is one of its key advantages over older methods like sign-and-magnitude, which had both +0 and −0.
A Number Plus Its Negative Gives Zero
If you take any number and add its two’s complement (i.e., its negative), the result is always zero (ignoring any overflow carry). For example:
0 0 0 0 0 1 0 1 (+5)
+ 1 1 1 1 1 0 1 1 (-5)
-----------------
1 0 0 0 0 0 0 0 0 (9th bit is discarded)
Result in 8 bits: 00000000 = 0
The 9th bit (the carry) is simply discarded, leaving a perfect zero. This is exactly why the method works so well.
Why Two’s Complement Is Used
The most important reason computers use two’s complement is that it simplifies the hardware. With two’s complement, the processor does not need separate circuits for addition and subtraction — the same addition circuit works for both positive and negative numbers. Subtraction is simply “add the two’s complement.” This means fewer transistors, simpler chip designs, faster calculations, and lower power consumption.
Interactive Exercise 1: Two’s Complement to Denary
Convert the following 8-bit two’s complement number to its denary (decimal) value. Remember: the MSB has a place value of −128.
Interactive Exercise 2: Denary to Two’s Complement
Convert the following negative denary number to its 8-bit two’s complement binary representation. Use the 3-step method: write the positive in binary, flip all bits, add 1.
Test Yourself
Click on each question to reveal the answer. Try to work it out on paper first — use the place value table or the 3-step method as appropriate.
Answer:
Place values: -128 64 32 16 8 4 2 1
Bits: 1 1 1 1 1 0 1 1
-128 + 64 + 32 + 16 + 8 + 2 + 1 = -5
The answer is −5.
Answer:
Step 1: +20 in binary = 00010100
Step 2: Flip all bits = 11101011
Step 3: Add 1 = 11101100
−20 in two’s complement is 11101100.
Check: −128 + 64 + 32 + 8 + 4 = −128 + 108 = −20. Correct!
Answer: The range is −128 to +127.
The formula for n bits is −2n−1 to +2n−1 − 1. For 8 bits: −27 to +27 − 1 = −128 to +127.
Answer: Two’s complement is preferred for several reasons:
- Simpler hardware: The same addition circuit can be used for both positive and negative numbers. Subtraction is just adding the two’s complement. This means fewer logic gates and simpler, cheaper processors.
- No double zero: Sign-and-magnitude has both +0 (00000000) and −0 (10000000), which wastes a value and complicates comparisons. Two’s complement has only one zero: 00000000.
- One extra value: Two’s complement can represent one additional negative number (−128 in 8-bit) because there is no wasted −0.
Answer:
Place values: -128 64 32 16 8 4 2 1
Bits: 1 0 0 0 0 0 0 1
-128 + 1 = -127
The answer is −127. Be careful not to mistake this for +129 (which is what you would get if you treated it as unsigned binary).
Answer: It represents zero. Since none of the bits are set, no place values are added: 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 = 0. Notice that the MSB is 0, so the sign bit indicates a non-negative number. Two’s complement has only one representation of zero, which is an advantage over sign-and-magnitude.
Answer:
Step 1: +1 in binary = 00000001
Step 2: Flip all bits = 11111110
Step 3: Add 1 = 11111111
−1 in two’s complement is 11111111 — all 1s.
Check: −128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = −128 + 127 = −1. Correct!
This is a well-known result: −1 is always all 1s in two’s complement, regardless of the number of bits.
Key Vocabulary
Make sure you know all of these terms for your exam:
| Term | Definition |
|---|---|
| Two’s Complement | A method for representing signed (positive and negative) integers in binary, where the MSB has a negative place value. Used by virtually all modern processors. |
| Sign Bit | The most significant bit in a signed binary number. In two’s complement, if the sign bit is 0, the number is positive (or zero); if it is 1, the number is negative. |
| Most Significant Bit (MSB) | The leftmost bit in a binary number. In unsigned binary, the MSB has the largest positive place value. In two’s complement, the MSB has a negative place value (e.g. −128 in 8-bit). |
| One’s Complement | The result of flipping (inverting) every bit in a binary number. It is the intermediate step when converting a positive number to its two’s complement negative form. |
| Signed Binary | A binary representation that can express both positive and negative integers. Two’s complement is the most common signed binary system. |
| Unsigned Binary | A binary representation that can only express zero and positive integers. All bits contribute positive place values (e.g. 128, 64, 32, 16, 8, 4, 2, 1 in 8-bit). |
Exam Tips
Past Paper Questions
Try these exam-style questions, then click to reveal the mark scheme answer.
Represent the denary number -45 as an 8-bit two's complement binary number. Show your working. [3] marks
Mark scheme:
- 45 in binary = 00101101 (1)
- Flip all bits: 11010010 (1)
- Add 1: 11010011 (1)
Convert the 8-bit two's complement binary number 10110100 to denary. [2] marks
Mark scheme:
- MSB is 1 so it's negative / -128 + 32 + 16 + 4 (1)
- Answer: -76 (1)
Explain what range of values can be represented using 8-bit two's complement. [1] mark
Mark scheme:
-128 to +127 (1)
Why Two’s Complement Matters
Two’s complement is not just an exam topic — it is the foundation of how every computer on Earth handles negative numbers. When you write temperature = -5 in Python or any other language, the processor stores that value using two’s complement. When a game character loses health points, or a bank processes a withdrawal, or a GPS calculates the direction you need to travel, two’s complement arithmetic is working behind the scenes.
The elegance of two’s complement lies in its simplicity: by making one small change (giving the MSB a negative weight), the same addition hardware works for both positive and negative numbers. This single insight, developed in the early days of computing, saved chip designers from building separate subtraction circuits and remains one of the cleverest ideas in all of computer science.
Understanding two’s complement also gives you a deeper appreciation of why computers have limits. When a 32-bit signed integer overflows past +2,147,483,647, it wraps around to −2,147,483,648 — a phenomenon that has caused real bugs in video games, financial software, and even spacecraft. Knowing how numbers are stored at the binary level makes you a better, more thoughtful programmer.
Video Resources
Further Reading
- BBC Bitesize — Edexcel GCSE Computer Science — Comprehensive coverage of binary and data representation topics
- GCSE Topic 2: Data Representation — Interactive revision tools and specification coverage for signed binary