AQA 7517, section 4.5.4.7
When choosing how to store numbers with fractional parts, you must compare fixed point and floating point on three things.
- Range: the difference between the smallest and largest values that can be stored.
- Precision: how finely the numbers can be represented, meaning how close together the stored values are, or how many significant digits are kept.
- Speed of calculation: how fast the computer can do arithmetic with them.
Fixed point
With a fixed point number, the point is at a set position.
Example: 8 bits in two's complement, with 4 bits before the point and 4 after.
- Range: up to ().
- Precision: the smallest step is . Every stored value is a multiple of 0.0625.
Giving more bits to the fractional part increases precision but reduces the range. Giving more bits to the whole part increases range but reduces precision. You can't have both with a fixed number of bits.
Floating point
A floating point number splits its bits between the mantissa and the exponent.
- A larger exponent gives a bigger range: the binary point can move further.
- A larger mantissa gives more precision: more significant bits are kept.
For the same total number of bits, floating point gives a far larger range, because the exponent works like a power of 2.
Example: a 16-bit fixed point number with 8 bits before the point has a range of about . A 16-bit floating point number with an 11-bit mantissa and a 5-bit exponent can reach about and can also represent very small numbers close to zero.
Precision in floating point is not constant. Numbers close to zero are stored very precisely (small gaps), while large numbers have bigger gaps between stored values. But the relative precision is about the same.
Comparing the two
| Fixed point | Floating point | |
|---|---|---|
| Range | Small for a given number of bits | Large, from very small to very large numbers |
| Precision | Constant: the same step size everywhere | Varies: very fine for small numbers, coarser for large ones |
| Speed | Faster: simple, like integer arithmetic | Slower: the exponents must be aligned and the result normalised |
| Hardware | Simple | More complex |
| Rounding errors | Large relative errors for small numbers | Relative error stays roughly the same |
| Typical use | Money, embedded systems, simple signal processing | Scientific work, graphics, general calculation |
Which should you choose?
- Use fixed point when the range is known and small, when you need speed and simplicity, or when the hardware is limited (such as a basic microcontroller).
- Use floating point when numbers could be very large or very small, or when you can't predict the range, such as in science and 3D graphics.
Worked example
Task: a program stores the mass of a planet (about kg) and the mass of an electron (about kg). Which format should it use?
These values differ by a factor of . A fixed point format would need an enormous number of bits to cover this range. Floating point is the right choice, because the exponent can set the scale, and the mantissa keeps a fixed number of significant digits for each value.
For storing prices in pence in a shop, fixed point or integers would do: the range is small and known, the calculations are fast, and the values are exact.
Exam tip: always compare range, precision and speed, and give one point for each format. For floating point, link range to the exponent and precision to the mantissa.
Check yourself
Give two advantages of floating point over fixed point
A much larger range for the same number of bits, and the ability to represent very small numbers precisely.
Give one advantage of fixed point over floating point
Arithmetic is simpler and faster, because it needs no exponent handling or normalisation.
In floating point, what does increasing the number of bits in the mantissa do? And in the exponent?
More bits in the mantissa increase the precision. More bits in the exponent increase the range.