Binary Addition & Subtraction (OCR A Level Computer Science): Revision Note

Exam code: H446

Robert Hampton

Written by: Robert Hampton

Reviewed by: James Woodhouse

Updated on

Binary Addition

What is Binary Addition?

  • Binary addition involves summing numbers in base-2, which uses only the digits 0 and 1

  • Like denary addition, start from the rightmost digit and move towards the left

  • Carrying over occurs when the sum of a column is greater than 1, passing the excess to the next left column

Example addition

binary-addition

Binary addition example

Overflow Errors

  • Overflow occurs when the sum of two binary numbers exceeds the given number of bits

  • In signed number representations, the leftmost bit often serves as the sign bit; overflow can flip this, incorrectly changing the sign of the result

  • Overflow generally leads to incorrect or unpredictable results as the extra bits are truncated or wrapped around

overflow

An overflow occurring after a binary addition

Binary Subtraction

  • As well as adding binary numbers, we can also subtract binary numbers

  • One method of doing this is to use two's complement

Example 1

Subtract 0011 (3) from 1001 (9)

1. Given numbers

Number 1

0

0

1

1

Number 2

1

0

0

1

2. Two's complement

  • Convert the number to subtract (0011) to its two's complement

  • Invert: 1100

  • Add 1: 1100 + 0001 = 1101

Number 1

1

0

0

1

Number 2 (Converted)

1

1

0

1

3. Addition operation

  • Now add 1001 and 1101

  • Binary sum: 1001 + 1101 = 1 0110

  • That’s 5 bits: the leftmost 1 is overflow (carry out of MSB)

Carry

1

 

 

1

 

Number 1

 

1

0

0

1

Number 2

 

1

1

0

1

Addition

1

0

1

1

0

4. Remove overflow

  • The result is 10110 with overflow

  • Drop the leading 1 (overflow): 0110 = 6 (in decimal)

  • In two's complement arithmetic, the overflow bit does not contribute to the actual value of the operation but is more of a by-product of the method

  • Final answer = 6

  • 9 - 3 = 6

You've read 0 of your 5 free revision notes this week

Unlock more, it's free!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Did this page help you?

Robert Hampton

Author: Robert Hampton

Expertise: Computer Science Content Creator

Rob has over 16 years' experience teaching Computer Science and ICT at KS3 & GCSE levels. Rob has demonstrated strong leadership as Head of Department since 2012 and previously supported teacher development as a Specialist Leader of Education, empowering departments to excel in Computer Science. Beyond his tech expertise, Robert embraces the virtual world as an avid gamer, conquering digital battlefields when he's not coding.

James Woodhouse

Reviewer: James Woodhouse

Expertise: Computer Science & English Subject Lead

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.