OCR Computing A-Level Revision

Data Representation

Floating Point Binary (3.4.a)

To represent large numbers in denary, we use standard form. This means that we use a small number (in the range 1.0 - 9.9), and we multiply it by a power of 10. This works because denary is base 10.

This method is also used to represent "real" numbers in binary - also known as "floating point" numbers (because the decimal point "floats" - it moves depending on the power of 2). Floating point numbers are made from two parts - the "mantissa" (equivalent to the small number in standard form) and the exponent (equivalent to the power of 10 in standard form). Both parts of the number are written in two's compliment - this means that if the first digit is a 1 then the number is negative.

n.b. - to secure full marks in the exam you will need to show full working - this is done by:

A normal "convert this number to decimal / denary" question would be worth 3 marks. Other questions which

Example 1 - a straightforward floating point number

Consider the following floating point number: 1000 1100 0100. The first 8 bits are the mantissa and the last 4 bits are the exponent.

Mantissa
-20 . 2-1 2-2 2-3 2-4 2-5 2-6 2-7
1 . 0 0 0 1 1 0 0
Exponent
-8 4 2 1
0 1 0 0

This represents the denary number 4.

We simply move the decimal point (in the mantissa) the number of places to the right as dictated by the exponent (a negative exponent means moving the decimal point to the left).

.
-24 23 22 21 20 . 2-1 2-2 2-3
1 0 0 0 1 . 1 0 0

This represents the denary number -14.5 (-16 + 1 + 1/2).

Example 2 - a negative exponent

Consider the following floating point number: 0011 1100 1010. The first 8 bits are the mantissa and the last 4 bits are the exponent.

Mantissa
-20 . 2-1 2-2 2-3 2-4 2-5 2-6 2-7
0 . 0 1 1 1 1 0 0
Exponent
-8 4 2 1
1 0 1 0

This represents the denary number -6. This means that we move the decimal point in the mantissa 6 places to the left (-6 places to the right). Because the first digit of the mantissa is a 0, we pad the mantissa with 0's.

.
-20 . 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 2-9 2-10 2-11 2-12 2-13
0 . 0 0 0 0 0 0 0 1 1 1 1 0 0

This represents the denary number 15/2048 (1/256 + 1/512 + 1/1024 + 1/2048) (~ 0.0073).

Example 3 - a negative exponent and a negative mantissa

Consider the following floating point number: 1100 1100 1101. The first 8 bits are the mantissa and the last 4 bits are the exponent.

Mantissa
-20 . 2-1 2-2 2-3 2-4 2-5 2-6 2-7
1 . 1 0 0 1 1 0 0
Exponent
-8 4 2 1
1 1 0 1

This represents the denary number -3. This means that we move the decimal point in the mantissa 3 places to the left (-3 places to the right). Because the first digit of the mantissa is a 1, we pad the mantissa with 1's.

.
-20 . 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 2-9 2-10
1 . 1 1 1 1 0 0 1 1 0 0

This represents the denary number -13/256 (-1 + 1/2 + 1/4 + 1/8 + 1/16 + 1/128 + 1/256) (~ -0.051).

Normalisation (3.4.b)

Consider the following numbers:

0111 0000 1100
0011 1000 1101
0001 1100 1110
0000 1110 1111

What makes them special?

They all represent the same number, however only the first one is normalised. Normalisation allows a number to be expressed as accurately as possible (for a given size mantissa).

A number is normalised if it's mantissa starts with 01 (positive) or 10 (negative).

Normalising a number

We can normalise a number by using the fact that when the exponent is negative, the mantissa is padded by the first digit of the mantissa. Therefore, we can remove any leading 0's or 1's which can be added back using padding - leaving the mantissa starting with 01 (if 0's are being removed - if the number is positive) or 10 (if 1's are being removed - if the number is negative). To add the leading digits back on, reduce the exponent by the number of bits removed.

Accuracy & Range (3.4.c)

The more bits that are used for the mantissa, the more accurate the floating point number will be. The most bits that are used for the exponent, the greater the range of numbers that can be represented. If the mantissa is not big enough to accurately store a number, then the nearest possible number is stored.