PAPER 2 - ⇑ Fundamentals of data representation ⇑

← Floating point normalisation Floating point errors Character_form_of_decimal_digit →



Significant digits

edit
  • What are the drawbacks of using floating point numbers?
  • What errors can you get?

Precision

edit

When using floating point numbers you have to balance the range and the precision of numbers. That is whether you want to have a very large range of values or you want a number that is very precise down to a large number of decimal places. This means that you are going to always weigh up how many digits should be used for the mantissa and how many should be used for the exponent. In summary:

  • If you want a very precise number use more digits for the mantissa and less for the exponent as this will allow for more decimal places.
  • If you want a large range of numbers use more digits for the exponent and less for the mantissa.

Rounding errors

edit

When we try to represent some numbers sometimes we can't within the space we have been given, for example trying to write down 1/3 = 0.33333333; you see what I mean? With floating point numbers you can't always get perfect precision and sometimes we suffer errors.

Feed this equation into Google:

999999999999999 - 999999999999998

The browser will perform a floating point calculation and give you the answer of 0!

So recognising that we can have rounding errors with floating point numbers we'll take a look at the different errors that might be caused. The following number wants to be represented in binary 23.27, the closest we get is 23.25.

Absolute errors

edit

This is the actual number difference between the desired value and the rounded value.

 

Where   means: make   positive.
Example 1:
|23.27 – 23.25| = 0.02 absolute error
Example 2:
|23.27 – 23.29| = 0.02 absolute error
Exercise: Absolute Errors

Give the absolute errors for the following:

when trying to represent 3.333 the closest you get in 3.25

Answer:

3.333 - 3.25 = 0.083

when trying to represent 12.67 the closest you get in 12.625

Answer:

12.67 - 12.625 = 0.045


Using 8 bit fixed point unsigned fraction with 4 bits for the decimal points:

find the absolute error trying to represent 8.8

Answer:

1000.1101 = 8.8125, the closest we can get
8.8 - 8.8125 = -0.0125

Relative error

edit

This is the percentage difference between the desired value and the rounded value.

 

Example:
(23.27 – 23.25) / 23.27 = 0.09%
Exercise: Relative Errors

Give the relative errors for the following:

when trying to represent 3.333 the closest you get in 3.25

Answer:

  • 3.333 - 3.25 = 0.083
  • (0.083 / 3.333)*100 = 2.49%

when trying to represent 12.67 the closest you get in 12.625

Answer:

  • 12.67 - 12.625 = 0.045
  • (0.045/12.67)*100 = 0.36%

Using 8 bit fixed point unsigned fraction with 4 bits for the decimal points:

find the absolute error trying to represent 8.8

Answer:

  • 1000.1101
  • 8.8 - 8.8125 = 0.0125
  • (0.0125/8.8)*100 = 0.14%

Cancellation error

edit

Adding a very small number to a very large number makes no difference to the large number, equations involving very large or small numbers will give you incorrect results. The web search engine example above is a good demonstration of this:

999999999999999 - 999999999999998 = 0

You might also see something like this:

999999999999999 - 1 = 0

Underflow

edit

When a number or the result of an equation is too small, you might not have enough digits in your mantissa and exponent to show it. In the following example the number would register as 0.

Try and show 0.0000000000000000000000000001 in 12 bit FP

Overflow

edit

When the result of a sum is too large to be represented by your number system, you might run out of space to represent it and end up storing a much smaller number.

Try and show 99,999,999,999,999,999,999 in 12 bit FP