A-level Computing/AQA/Paper 2/Fundamentals of data representation/Floating point normalisation

From testwiki
Jump to navigation Jump to search

Template:CPTPageNavigationP2


When storing numbers we need to use the space we are given in the most efficient way. For instance if we take a denary floating point number such as

 6.6310×1034 (Planck's constant)

If we were to rewrite it as:

 0.066310×1032 (Planck's constant)

Then you can see the representation takes up an extra 2 characters, the two extra 0's, even though it represents exactly the same number. This may be acceptable when you are not worried about how many characters a number makes up, but in binary and with limited computer memories, the space that numbers take up is very important. We need the most efficient representation we can. With a fixed number of bits, a normalised representation of a number will display the number to the greatest accuracy possible. In summary normalised numbers:

  • Give only one representation of a number.
  • Save space.
  • Give the most accurate representation of a number in a given number of bits.

As a rule of thumb: when dealing with Floating point numbers in binary you must make sure that the first two bits are different. That is:

0.1
1.0

And most definitely NOT

1.1
0.0

Let's look at an example. Taking a binary floating point number:

0.010000000000011

We can see that the number starts with 0.01. We need to change this to 0.1 for it be normalised. To do this we need to move the decimal place one position to the right, and to retain the same number represented by the unnormalised number we need to change the exponent accordingly. With a movement one place right to normalise the number we need to change the exponent to move the decimal point one place left to compensate. Thus subtracting one from the current exponent:

0.100000000000010

To make sure you have normalised it correctly, check that

0.010000000000011=0.100000000000010

Lets try a more complicated example:

1.110000000111110

To get the mantissa normalised we need to move the decimal point two places to the right. To maintain the same value as the original floating point number we need to adjust the exponent to be two smaller.

1.000000000111100

Now check that the new normalised value has the same value as the original. Template:CPTAmbox

Template:ExampleRobox Template:CPTRuleTab

  1. Normalise the left hand side (mantissa).
  2. Record the number of ‘bounces’ it has taken to normalise.
  3. Work out the exponent of the normalised number by using: original exponent – ‘bounce’.

Template:CPTRuleEnd

  • Normalised numbers start with 2 bits that are different.
  • Make sure that your normalisation does not change the sign of the mantissa.
  • Normalisation provides the maximum precision for a given number of bits.
  • Normalisation makes sure there is only one representation for each number

Template:Robox/Close

Template:CPTExercise Template:CPTQuestion Template:CPTAnswer Template:CPTQuestion Template:CPTAnswer Template:CPTQuestion Template:CPTAnswer Template:CPTQuestion Template:CPTAnswerTab

  1. 0.010000000 111111 -> 00.10000000 111111
  2. One place to the right
  3. 111111 - 1 = -1 -1 = -2 = 000010 (+2) = 111110 (-2)
00.10000000 111110 = 0.100000000 111110

Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab

  1. 0.001101000 000110 -> 000.1101000 000110
  2. Two places to the right
  3. 000110 - 2 = 6 - 2 = 4 = 000100 (+4)
000.1101000 000100 = 0.110100000 000100

Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab

  1. 1.111111010 000011 -> 1111111.010 000011
  2. Six places to the right
  3. 000011 - 6 = 3 - 6 = -3 = 111101 (-3)
111111.010 111101 = 1.01000000 111101

Template:CPTAnswerTabEnd Template:Robox/Close Template:BookCat