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

Exam code: H446

Robert Hampton

Written by: Robert Hampton

Reviewed by: James Woodhouse

Updated on

Floating Point Arithmetic

How do you represent Floating Point Numbers?

  • Floating point numbers are represented with a sign, mantissa, and exponent

  • Arithmetic operations must take into account these three components

sign-mantissa-exponent-1

Sections of a floating point number

Steps for adding or subtracting floating point numbers

  1. Ensure the numbers have the same exponent before performing arithmetic

    • This might involve shifting the decimal point of one number and adjusting its exponent until both numbers have matching exponents.

    • Example:

      • Number A: 1.101×2 cubed

      • Number B: 1.010×2 squared

      • Number A has an exponent of 2 cubed and B has an exponent of 2 squared, we need to adjust B to have the same exponent as A

      • This is achieved by moving the point one space to the left in Number B and increasing the exponent by 1

      • Resulting in: 0.101×2 cubed

  2. Perform the binary addition or subtraction on the mantissa

    • 1.101 space plus space 0.101 space equals space 10.010

  3. Ensure the result is in a normalised form

    • The sum 10.010 exceeds the normal range for mantissa (1.0 to 1.111... in binary)

    • To normalise it, we shift the mantissa one position to the right and increment the exponent by 1

    • New Mantissa: 1.0010

    • New Exponent: Increment the exponent from 2 cubed to 2 to the power of 4

    • The final result would be 1.0010×2 to the power of 4.

  4. Determine Sign

    • For addition: If both numbers are positive or negative, the result takes the common sign

    • If they have different signs, the result's sign depends on the larger absolute value

    • For subtraction: The sign is determined by the sign of the number you're subtracting from and the result of the subtraction

Example addition

  1. 1.100 1 subscript 2 cross times 2 cubed + 1.011 0 subscript 2 cross times 2 squared

  2. Align exponents: 1.100 1 subscript 2 cross times 2 cubed + 0.101 1 subscript 2 cross times 2 cubed

  3. Add mantissa: 10.010 0 subscript 2

  4. Normalise (if required) and determine the sign.

Example subtraction

  1. 1.100 1 subscript 2 cross times 2 cubed - 1.011 0 subscript 2 cross times 2 squared

  2. Align exponents: 1.100 1 subscript 2 cross times 2 cubed - 0.101 1 subscript 2 cross times 2 cubed

  3. Subtract mantissas: 0.111 0 subscript 2

  4. Normalise (if required) and determine the sign.

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.