Binary Arithmetic (Cambridge (CIE) A Level Computer Science): Revision Note

Exam code: 9618

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

Worked Example

Add the following two binary integers using binary addition. Show your working. [2]

1 0 0 1 1 0 1 0 + 0 0 1 0 1 1 1 1

Answer

carry

1

1

1

1

1

1

0

0

1

1

0

1

0

+

0

0

1

0

1

1

1

1

1

1

0

0

1

0

0

1

  • 1 mark for working [1 mark]

  • 1 mark for answer [1 mark]

Overflow

What is an overflow?

  • 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

Binary subtraction

  • To carry out subtraction, the number being subtracted is converted into its negative equivalent using two's complement

  • The two numbers are then added together

Example

  • 48 - 12

-128

64

32

16

8

4

2

1

0

0

1

1

0

0

0

0

= 48

0

0

0

0

1

1

0

0

= 12

find two's complement of -12

0

0

0

0

1

1

0

0

= 12

invert

1

1

1

1

0

0

1

1

add 1

1

result

1

1

1

1

0

1

0

0

= -12

Add 48 and -12

-128

64

32

16

8

4

2

1

0

0

1

1

0

0

0

0

= 48

1

1

1

1

0

1

0

0

= -12

carries

1

1

1

1

result

0

0

1

0

0

1

0

0

= 36

  • 48 - 12 = 36

  • The additional overflow bit is ignored leaving a result of 0010 0100, denary equivalent of 36, which is the correct answer

  • 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

👀 You've read 1 of your 5 free revision notes this week
An illustration of students holding their exam resultsUnlock more revision notes. It’s free!

By signing up you agree to our Terms and Privacy Policy.

Already have an account? Log in

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.

Download notes on Binary Arithmetic