Floating-point numbers
| English | Chinese | Pinyin |
|---|---|---|
| floating-point | 浮点 | fú diǎn |
| mantissa | 尾数 | wěi shù |
| exponent | 指数 | zhǐ shù |
| normalised | 规格化 | guī gé huà |
| precision | 精度 | jīng dù |
| rounding errors | 舍入误差 | shě rù wù chā |
| fixed-point | 定点 | dìng diǎn |
| overflow | 溢出 | yì chū |
| underflow | 下溢 | xià yì |
A missile that missed by 600 metres
- On 25 February 1991 a Patriot battery at Dhahran failed to intercept an incoming missile. Twenty-eight soldiers died.
- The system counted time in tenths of a second, and 0.1 has no exact binary representation: it is a repeating fraction, truncated to the register's width. Each tick lost a fraction of a microsecond.
- After a hundred hours running, the accumulated error was a third of a second, and in a third of a second the target moved 600 metres. The arithmetic was correct at every single step.
- This lesson is the floating-point 浮点 format, normalisation 规格化, and the approximation errors that make cases like this possible.
The format
- To store real numbers of very different sizes, a computer uses a binary form of scientific notation with two fields: a mantissa 尾数, the significant digits, and an exponent 指数, the power of 2 to multiply by. Both are stored as two's complement.
- Read the mantissa as a binary fraction: the first bit after the point is worth $\tfrac12$, the next $\tfrac14$, then $\tfrac18$. So
0.1010000is $\tfrac12 + \tfrac18 = 0.625$. - With exponent
00000010, that is $+2$, the value is $0.625 \times 2^2 = 2.5$.

A fraction and a power of two
Build a floating-point number
Flip the mantissa and exponent bits to make a value, and check whether it is normalised.
A floating-point number is stored as:
value = mantissa × 2^exponent — binary scientific notation, with both parts stored in two's complement.
Match each part of floating-point representation to its role.
value = mantissa × 2^exponent; normalising maximises precision; money uses fixed-point/BCD to avoid rounding.
Worked example: binary to denary
- A number has mantissa
10110000and exponent00000011. Find its denary value. - The exponent is $+3$. The mantissa begins with 1, so it is negative and is read by two's complement rules: as
1.0110000the sign bit is worth $-1$ and the fraction bits add $\tfrac14 + \tfrac18 = 0.375$, so the mantissa is $-1 + 0.375 = -0.625$. - $\text{number} = -0.625 \times 2^3 = -5.0$.
- The commonest error is reading a negative mantissa as if it were positive. Check the first bit before anything else.
A floating-point number has mantissa 10110000 and exponent 00000011. What is its denary value?
The mantissa starts with 1, so it is negative: −1 + 1/4 + 1/8 = −0.625. Times 2^3 gives −5.0. Reading it as positive is the usual error.
Worked example: denary to binary
- Store $+2.5$ in the same 8-bit mantissa, 8-bit exponent format.
- In binary, $2.5 = 10.1$. Written as a fraction times a power of two: $2.5 = 0.101 \times 2^2$.
- So the mantissa is
01010000, a sign bit of 0 then.101padded with zeros, and the exponent is00000010. - Always write it in the normalised form first; then the two fields read straight off.
Written as a normalised fraction times a power of two, 2.5 = 0.101 x 2^__. Give the exponent.
2.5 is 10.1 in binary; sliding the point two places left gives 0.101, so the exponent is 2 and the mantissa is 01010000.
Normalisation
- A number is normalised when the first significant bit sits immediately after the binary point, so there are no wasted leading zeros. For a positive number the mantissa starts
0.1; for a negative one,1.0. - Why: it maximises precision 精度, because every mantissa bit then carries information rather than a leading zero.
- To normalise, shift the mantissa left and decrease the exponent by the same number of places, or shift right and increase it. The value is unchanged; only its representation is.

Shift the bits, adjust the exponent, keep the value
Trading mantissa bits against exponent bits
- The total number of bits is fixed, so the two fields compete.
- More mantissa bits means greater precision: each value is stored more exactly, with a smaller rounding error.
- More exponent bits means greater range: much larger and much smaller magnitudes can be represented, but each one less precisely.
- A question asking for the effect of moving a bit from one field to the other wants exactly this trade: range against precision.
Normalising a floating-point number
Step through normalisation. Shifting the mantissa to remove wasted leading zeros — and adjusting the exponent to match — keeps the value the same but spends every bit on precision.
Normalising a floating-point number:
Normalisation shifts the mantissa so the first significant bit follows the point — every bit then carries information, and the value is unchanged.
Which are true of normalising a floating-point number? Select all that apply.
Normalising changes only the representation. The value is unchanged; that is what adjusting the exponent guarantees.
Approximation and its consequences
- Many denary reals cannot be stored exactly in binary. $0.1$ is the repeating fraction $0.000110011\ldots$, so it must be truncated: the stored value is close to $0.1$ but never equal to it.
- Rounding errors 舍入误差 accumulate over many operations, which is why
0.1 + 0.2is not exactly0.3and why the Patriot's clock drifted. - So never test two reals for equality: write
ABS(x - 0.3) < 1e-9instead ofx = 0.3. And beware subtracting two nearly equal values, which throws away most of the significant digits. - For values that must be exact, currency above all, use fixed-point 定点 or BCD instead.
Match each change in the bit allocation to its effect.
The word size is fixed, so precision and range trade against each other; overflow and underflow are the exponent field running out at each end.
Overflow and underflow
- Overflow 溢出 happens when a result is too large for the exponent's range, so it cannot be represented at all.
- Underflow 下溢 happens when a result is too small, so close to zero that the exponent cannot go low enough, and it rounds to zero.
- Both are properties of the exponent field's size, which is the other half of the trade-off above.
0.1 cannot be stored exactly in binary (it is a repeating fraction), so 0.1 + 0.2 does not give exactly 0.3 on a computer.
The tiny approximation errors add up — which is why money is handled with fixed-point or BCD, not floating-point.
For exact money calculations you should use:
Floating-point rounding errors are unacceptable for currency; fixed-point or BCD store decimal values exactly.
Marks that slip away
- The mantissa is a fraction, not an integer: the first bit after the point is a half.
- A mantissa starting with 1 is negative and follows two's complement rules. Check that bit first.
- Normalisation maximises precision; it does not change the value, and it does not make the number bigger.
- More mantissa means precision, more exponent means range. Overflow is too big, underflow is too small.
You've got it
- floating point stores $\text{mantissa} \times 2^{\text{exponent}}$, both in two's complement; the mantissa is a binary fraction
- convert by reading the mantissa as a fraction (two's complement if it starts with 1) and multiplying by two to the exponent
- normalised means the first significant bit is immediately after the point, which maximises precision; shifting left lowers the exponent
- more mantissa bits give precision, more exponent bits give range; binary cannot store many reals exactly, so expect rounding errors, compare with a tolerance, and use fixed-point or BCD for currency