Binary Arithmetic & Two's Complement (OCR A-Level CS 1.4.1)

OCR A-Level CS 1.4.1: adding and subtracting binary, overflow, sign and magnitude vs two's complement for negative numbers, and subtraction by two's complement.


Free Binary Arithmetic Two's Complement revision resources (OCR A-Level Computer Science, 1.4.1)

We’ve made exam-style practice for this exact topic, free to download: Binary Arithmetic Two's Complement question sheet, mark scheme and cheat sheet. Grab them, have a go, then read the full guide below.

Once you can write numbers in binary, the next step is doing maths with them — and storing negative numbers. Spec points 1.4.1(c) and (d) cover adding and subtracting binary integers, representing negatives with sign-and-magnitude and two's complement, and using two's complement to subtract. These are reliable Paper 1 marks, and the method is always the same once you've drilled it.

Let's work through addition, the two ways to store negatives, and the neat trick that turns subtraction into addition.

Adding binary numbers

Binary addition works column by column, right to left, exactly like denary but with only four rules:




For example 00010101 + 00010101:




Overflow

If a calculation produces a result that needs more bits than are available, you get an overflow error. Adding two 8-bit numbers whose total exceeds 255 would need a 9th bit, which can't be stored in one byte — the carry out of the top column is lost, giving a wrong answer. Overflow is the computer running out of room to hold the result.

Storing negatives 1: sign and magnitude

The simplest way to store a negative is sign and magnitude: use the most significant bit (MSB) as a sign (0 = positive, 1 = negative) and the remaining bits for the size (magnitude). In one byte:




It's easy to read, but it has two problems: there are two representations of zero (00000000 and 10000000), and — more importantly — ordinary addition doesn't work. Add +3 and −9 as plain binary and you don't get −6. That makes the hardware more complicated, which is why processors don't use it.

Storing negatives 2: two's complement

Two's complement fixes both problems and is what real processors use. The clever idea: the most significant bit has a negative place value. For 8 bits the place values become:

So a number with a 1 in the top bit is negative. To find the two's complement representation of a negative number, there's a reliable method:

  1. Write the positive value in binary.

  2. Flip every bit (0↔1) — this is the one's complement.

  3. Add 1.

For example, −101 in 8 bits: 101 is 01100101; flip → 10011010; add 1 → 10011011. Check using place values: −128 + 16 + 8 + 2 + 1 = −101. ✓

Two's complement has only one zero and lets you use normal binary addition for signed numbers — which is exactly why it's preferred.

Subtraction using two's complement

Here's the payoff. To compute A − B, you don't subtract at all — you add the two's complement of B:

A − B = A + (−B)

Worked example: 124 − 101 in 8-bit two's complement.




Add the two bytes and discard the carry out of the top (the 9th bit). The result is 00010111 = 23, which is correct (124 − 101 = 23). The single carry that "falls off the end" is expected and ignored in two's complement.

Common exam mistakes

  • Forgetting "+1" in two's complement. Flip the bits and add one — the one's complement alone is wrong.

  • Subtracting instead of adding. Two's complement turns subtraction into A + (−B); convert B to its two's complement, then add.

  • Panicking about the final carry. In two's complement subtraction, a carry out of the top bit is discarded — that's normal.

  • Missing overflow. If a result needs a 9th bit, say overflow — don't just write the wrong truncated value with no comment.

  • Mixing up the two negative methods. Sign and magnitude uses the MSB as a flag; two's complement gives the MSB a negative weight (−128).

Quick recap

  • Binary addition: column by column with carries; if the result needs more bits than available, that's overflow.

  • Sign and magnitude: MSB = sign. Simple but has two zeros and normal addition fails → not used by processors.

  • Two's complement: MSB has place value −128; form a negative by flip the bits + 1. One zero, normal addition works.

  • Subtraction: A − B = A + (two's complement of B); discard the carry off the top bit.

  • Two's complement is preferred because arithmetic just works with standard adders.

Frequently asked questions

What is overflow in binary addition? Overflow occurs when the result of a calculation needs more bits than are available to store it. For example, adding two 8-bit numbers whose total exceeds 255 would require a ninth bit, which cannot be held in one byte, so the result is incorrect and an overflow error occurs.

How do you represent a negative number using sign and magnitude? In sign and magnitude, the most significant bit is used as a sign (0 for positive, 1 for negative) and the remaining bits store the magnitude. For example, in one byte +3 is 00000011 and −9 is 10001001.

How do you find the two's complement of a number? Write the positive value in binary, flip every bit to get the one's complement, then add one. For example, −101 in eight bits is 01100101 flipped to 10011010, then add one to give 10011011.

Why is two's complement preferred over sign and magnitude? Two's complement has only one representation of zero and lets the computer use ordinary binary addition for signed numbers, including subtraction. Sign and magnitude has two zeros and ordinary addition does not give correct results, so it needs more complex hardware.

How do you subtract binary numbers using two's complement? To work out A minus B, convert B to its two's complement (its negative) and add it to A using normal binary addition. Any carry out of the most significant bit is discarded. For example, 124 − 101 becomes 124 + (−101) = 00010111 = 23.

Why does the most significant bit in two's complement represent a negative value? In two's complement the place value of the most significant bit is made negative (for example −128 in an 8-bit number) while the other bits stay positive. This means a number with a 1 in the top bit is negative, and it allows a single, consistent method of addition to work for both positive and negative numbers.

 

 

 

Logo

All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, trademarks and brands does not imply endorsement.


Follow us on:

Icon
Icon
Icon
Icon
Icon

Support@shuttlelearning.com

Logo

All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, trademarks and brands does not imply endorsement.


Follow us on:

Icon
Icon
Icon
Icon
Icon

Support@shuttlelearning.com

Logo

All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, trademarks and brands does not imply endorsement.


Follow us on:

Icon
Icon
Icon
Icon
Icon

Support@shuttlelearning.com