- How 8-bit unsigned integers represent denary values from 0 to 255.
- How two's complement represents signed integers from -128 to +127.
- How to convert between 8-bit binary and denary for both representations.
- How computers manipulate these integers using addition, subtraction, shifts and overflow rules.
An integer is a whole number, such as 0, 42, -7 or 255. Computers store integers using bits, where each bit is either 0 or 1.
Bit, byte and bit pattern
A bit is a single binary digit, either 0 or 1. A byte is 8 bits. A bit pattern is a particular sequence of bits, such as 0110 1001.
For GCSE, you usually work with 8-bit binary numbers. We group the 8 bits into two nibbles of 4 bits to make them easier to read:
10110101 becomes 1011 0101
In an unsigned 8-bit number, the place values are:
| Bit position | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|
| Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
The leftmost bit is the most significant bit because it has the largest place value. The rightmost bit is the least significant bit because it has the smallest place value.
Converting unsigned binary to denary
Convert 1011 0101 to denary.
-
Match each bit to its unsigned place value: 1 0 1 1 0 1 0 1 lines up with 128 64 32 16 8 4 2 1.
-
Add the place values where the bit is 1: 128 + 32 + 16 + 4 + 1.
-
Calculate the total: 1011 0101 represents 181 as an unsigned integer.
An unsigned integer cannot be negative. Every bit is used for the size of the number, so 8 bits can store values from 0 to 255.
Unsigned integer
An unsigned integer is a whole number with no sign bit, so it represents zero or a positive value only.
With 8 bits, there are 28=2562^8 = 25628=256 possible bit patterns. Because counting starts at 0, the largest unsigned value is 255:
- Smallest:
0000 0000 = 0
- Largest:
1111 1111 = 255
Unsigned 8-bit range
For Edexcel GCSE, an 8-bit unsigned integer has the range 0 to 255.
Representing denary as unsigned binary
Represent denary 156 as an 8-bit unsigned binary number.
-
Start with the largest place value, 128. Since 156 is at least 128, put a 1 in the 128 column and subtract it, leaving 28.
-
Check the next place values: 64 and 32 are too large, so put 0s there. 16 fits into 28, so put a 1 and subtract 16, leaving 12.
-
Continue with 8, 4, 2 and 1: 8 fits, leaving 4; 4 fits, leaving 0; 2 and 1 do not fit.
-
The bits are 1001 1100, so denary 156 is 1001 1100 as an 8-bit unsigned integer.
A signed integer can be positive, negative or zero. GCSE Computer Science uses two's complement to represent signed integers.
The important idea is that the same 8-bit pattern can mean different denary values depending on whether it is being interpreted as unsigned or two's complement.

Two's complement
Two's complement is a method for representing signed binary integers where, in 8 bits, the leftmost bit has the value -128 instead of +128.
For 8-bit two's complement, the place values are:
| Bit position | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|
| Place value | -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
This gives the range:
- Smallest:
1000 0000 = -128
- Largest:
0111 1111 = +127
Check the sign bit
In 8-bit two's complement, if the leftmost bit is 0, the value is zero or positive. If the leftmost bit is 1, the value is negative.
Interpreting a two's-complement number
Convert 1101 0110 from 8-bit two's complement to denary.
-
Use the two's-complement place values: -128 64 32 16 8 4 2 1.
-
Add the values where the bit is 1: -128 + 64 + 16 + 4 + 2.
-
Calculate the result: -128 + 64 + 16 + 4 + 2 = -42, so 1101 0110 represents -42.
To represent a negative number in 8-bit two's complement, one reliable method is:
- Write the positive version in 8-bit binary.
- Flip every bit: 0 becomes 1, and 1 becomes 0.
- Add 1.
This is called the “flip and add 1” method.
Representing a negative number in two's complement
Represent -37 as an 8-bit two's-complement number.
-
Write +37 in 8-bit binary: 37 = 0010 0101.
-
Flip every bit: 0010 0101 becomes 1101 1010.
-
Add 1: 1101 1010 + 0000 0001 = 1101 1011.
-
Therefore, -37 is represented as 1101 1011.
Forgetting the fixed 8-bit width
Always keep all 8 bits when using two's complement. For example, +5 is 0000 0101, not just 101, before you flip bits.
The edge of the range
In 8-bit two's complement, -128 is valid but +128 is not. The range is -128 to +127, so a result of +128 causes overflow.
Computers manipulate integers by carrying out binary operations such as addition. The bit addition rules are the same whether the number is unsigned or two's complement, but the meaning of the result depends on how you interpret the bits.
Overflow
Overflow happens when the result of a calculation is outside the range that can be represented using the available number of bits.
For 8-bit unsigned integers, overflow happens if the result is less than 0 or greater than 255.
For 8-bit two's-complement integers, overflow happens if the result is less than -128 or greater than +127.

Adding two signed integers
Add 75 and 90 using 8-bit two's complement.
-
Convert both positive numbers to 8-bit binary: 75 is 0100 1011 and 90 is 0101 1010.
-
Add the bit patterns: 0100 1011 + 0101 1010 = 1010 0101.
-
Interpret the result as two's complement. The leftmost bit is 1, so the result is negative: -128 + 32 + 4 + 1 = -91.
-
Since adding two positive numbers should not give a negative number, and the true answer 165 is outside the range -128 to +127, overflow has occurred.
Signed overflow sanity check
In two's complement, adding two positive numbers should give a positive result. Adding two negative numbers should give a negative result. If the sign unexpectedly changes, suspect overflow.
Two's complement is useful because subtraction can be handled as addition of a negative number.
For example:
6 - 9 can be treated as 6 + (-9)
Subtracting using two's complement
Calculate 6 - 9 using 8-bit two's complement.
-
Rewrite the subtraction as addition: 6 + (-9).
-
Represent both numbers in 8-bit two's complement: 6 is 0000 0110; -9 is found from 256 - 9 = 247, so it is 1111 0111.
-
Add the bit patterns: 0000 0110 + 1111 0111 = 1111 1101.
-
Interpret 1111 1101 as two's complement: -128 + 64 + 32 + 16 + 8 + 4 + 1 = -3, so the calculation gives -3.
A binary shift moves all bits left or right. Shifts are a quick way to multiply or divide by powers of 2, but bits can be lost, so overflow and sign changes matter.
A logical shift fills the empty positions with 0s. It is normally used with unsigned integers.
An arithmetic shift preserves the sign of a two's-complement signed integer. For an arithmetic right shift, the leftmost bit is copied into the new empty spaces.
What shifts do
A left shift by one place usually multiplies by 2. A right shift by one place usually divides by 2 using integer division, but signed negative numbers need an arithmetic right shift to keep the sign correct.
Arithmetic right shift of a negative number
Arithmetic right shift 1111 1000 one place to the right.
-
Interpret the original number as two's complement: 1111 1000 has value -128 + 64 + 32 + 16 + 8 = -8.
-
Shift all bits one place to the right and copy the sign bit 1 into the leftmost position: 1111 1000 becomes 1111 1100.
-
Interpret the result: 1111 1100 has value -128 + 64 + 32 + 16 + 8 + 4 = -4, so the arithmetic right shift has divided -8 by 2.
Using a logical shift on a signed negative number
A logical right shift of 1111 1000 would give 0111 1100, which is positive. For two's-complement negative numbers, use an arithmetic right shift to preserve the sign.
In the exam
-
First identify the representation: unsigned or two's complement. The same bit pattern can mean different denary values.
-
Write the 8-bit place values above the bits before converting. Use 128 64 32 16 8 4 2 1 for unsigned, but -128 64 32 16 8 4 2 1 for two's complement.
-
Check the allowed range: unsigned is 0 to 255; two's complement is -128 to +127.
-
For addition, calculate the 8-bit result, then decide whether overflow has occurred based on the chosen representation.
-
For right shifts, decide whether the question needs a logical shift or an arithmetic shift.
Check yourself
- What denary value does
1111 1111 represent as unsigned, and what does it represent as two's complement?
- How would you represent -18 using 8-bit two's complement?
- Why does
0111 1111 + 0000 0001 cause overflow for two's complement but not for unsigned?