All subjects · Computer Science · WCP01 Principles of Computer Science
Binary addition, subtraction, overflow and underflow
Edexcel IAL Computer Science · WCP01 Principles of Computer Science
Binary is added column by column like denary, carrying 1 when a column reaches 2. Subtraction in two's complement is done by adding the negative. When a result does not fit, overflow occurs (spec points 2.2.1 and 2.2.3).
Binary addition rules
- 0 + 0 = 0
- 0 + 1 = 1
- 1 + 1 = 10 (write 0, carry 1)
- 1 + 1 + 1 = 11 (write 1, carry 1)
Example (unsigned): 0110 1101 (109) + 0011 1010 (58) = 1010 0111 (167). Always show the carries in an exam.
Subtraction with two's complement
To work out A - B, find the two's complement of B (invert, add 1) and add it to A. Ignore any carry out of the MSB.
Example: -37 - 21 in 8 bits, worked as -37 + (-21): 1101 1011 + 1110 1011 = 1100 0110 with a carry out of 1, which is discarded. 1100 0110 = -58. Correct.
Overflow and underflow
- Overflow happens when the result of a calculation is too large (in size) to be represented in the bits available. Unsigned: there is a carry out of the MSB. Signed: adding two numbers with the same sign gives a result with the opposite sign. Example: 100 + 60 in 8-bit two's complement gives 1010 0000, which reads as -96, not 160.
- Underflow happens when a result is too small (too close to zero) to be represented accurately in the bits available, for example a very small fractional number divided by a large one, or a right shift of a fixed-point value, giving a result smaller than the smallest step, so it is stored as 0 or loses precision. A result that is too negative, such as -100 - 60 in 8-bit two's complement, is overflow, not underflow: it is too large in size.
- The CPU sets the carry or overflow flag in the status register so programs can detect the problem. Undetected overflow gives wrong results.
Worked example
Calculate 45 - 19 using 8-bit two's complement.
- 45 = 0010 1101
- 19 = 0001 0011, so -19 = 1110 1101
- Add: 0010 1101 + 1110 1101 = 0001 1010, carry out 1 discarded
Answer: 0001 1010 = 26
Check yourself
- Add the unsigned 8-bit numbers 0011 0110 and 0100 1011. Give the 8-bit result.
Show answer
10000001. 54 + 75 = 129 = 1000 0001.
- What is the denary value of 0101 1101 + 0010 0111 (unsigned)?
Show answer
132. 93 + 39 = 132.
- Calculate 30 - 47 using 8-bit two's complement. Give the 8-bit result.
Show answer
11101111. 30 = 0001 1110; -47 = 1101 0001; sum = 1110 1111 = -17.
- In 8-bit two's complement, 0101 1010 + 0011 0010 is calculated. What denary value does the 8-bit result appear to represent?
Show answer
-116. The sum pattern is 1000 1100, whose MSB is 1, so it reads as -116. 140 is out of range: overflow.
- Two positive two's complement numbers are added and the result has an MSB of 1. What has happened?
- Underflow
- Overflow
- A correct negative result
- A logical shift
Show answer
Overflow. Two positives cannot make a negative; the result was too large.
- When adding two unsigned 8-bit numbers, what shows that overflow has happened?
- A 0 in the least significant bit
- The result is even
- The result has more 1s than 0s
- A carry out of the most significant bit
Show answer
A carry out of the most significant bit. The ninth bit cannot be stored.
- Which is an example of underflow?
- Adding 1 to 255 in an unsigned byte
- A fractional result is so close to zero that it is stored as 0
- Converting binary to hexadecimal
- Shifting a pattern one place left
Show answer
A fractional result is so close to zero that it is stored as 0. Underflow: too small to represent. Adding 1 to 255 is overflow.
- Using 8-bit unsigned binary, what is the largest number that can be added to 200 without causing overflow?
Show answer
55. 200 + x must be at most 255, so x = 55.
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.