mrahmedcomputing

KS3, GCSE, A-Level Computing Resources

Lesson 6. Floating Point Arithmetic


Lesson Objective

  • Be able to carry out floating point arithmetic.
  • Be able to carry out floating point subtraction.

Lesson Notes

Floating Point Arithmetic

1. These are the floating point numbers we are adding.

Mantissa Exponent
-1 1/2 1/4 1/8 1/16 -4 2 1
0 1 0 1 0 0 1 1
0 1 0 1 1 0 0 1

2. Put the point in the correct place. Using the Exponent.

0 1 0 1 0 0 1 1

0 1 0 1 1 0 0 1

3. Convert to fixed point. Line up the decimal points. Add 0's in the extra places.

-8 4 2 1 1/2 1/4 1/8 1/16
0 1 0 1 0 0 0 0
0 0 0 1 0 1 1 0

4. Normal addition on both numbers.

1
0 1 0 1 0 0 0 0 ?
+ 0 0 0 1 0 1 1 0 ?
0 1 1 0 0 1 1 0 ?

5. Normalise the binary number. Move the decimal point 3 spaces to the left. Positive number, msb must be 0, 2nd msb must be 1. Exponent is +3 because the point would have to move 3 spaces to the right to return the original value.

Mantissa Exponent
-1 1/2 1/4 1/8 1/16 1/32 1/64 1/128 -4 2 1
0 1 1 0 0 1 1 0 0 1 1

Floating Point Subtraction

1. These are the floating point numbers we are subtracting.

Mantissa Exponent
-1 1/2 1/4 1/8 1/16 -4 2 1
0 1 1 0 0 0 1 0
0 1 0 1 0 0 1 1

2. Put the point in the correct place. Using the Exponent.

0 1 1 0 0 0 1 0

0 1 0 1 0 0 1 1

3. Convert to fixed point. Line up the decimal points. Add 0's in the extra places.

-8 4 2 1 1/2 1/4 1/8 1/16
0 0 1 1 0 0 0 0
0 1 0 1 0 0 0 0

4. Normal subtraction of the numbers. Flip and add one. Digits to the right of the decimal point stay the same.

0 1 0 1 0 0 0 0 5
1 0 1 0 0 0 0 0
+ 0 0 0 1
1 0 1 1 0 0 0 0 -5

5. Add the positive and negative number.

1
0 0 1 1 0 0 0 0 3
+ 1 0 1 1 0 0 0 0 -5
1 1 1 0 0 0 0 0 -2

6. Normalise the numbers.

Mantissa Exponent
-1 1/2 1/4 1/8 1/16 1/32 1/64 1/128 -4 2 1
1 0 0 0 0 0 0 0 0 1 0