| English | 意味 |
|---|---|
| floating-point/ˈfləʊtɪŋ pɔɪnt/ | 浮動小数点 |
| mantissa/mænˈtɪsə/ | 尾数 |
| exponent/ekˈspəʊnənt/ | 指数 |
| normalised/ˈnɔːməlaɪzd/ | 正規化 |
| precision/prɪˈsɪʒn/ | 精度 |
| rounding errors/ˈraʊndɪŋ ˈerəz/ | 丸め誤差 |
| fixed-point/fɪkst pɔɪnt/ | 固定小数点 |
| overflow/ˌəʊvəˈfləʊ/ | オーバーフロー |
| underflow/ˌʌndəˈfləʊ/ | アンダーフロー |
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
浮動小数点数を構築する
mantissa(尾数)と指数ビットを反転させて値を作成し、正規化されているか確認する。
浮動小数点数は以下のように格納される:
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
値 = mantissa × 2^指数 — 二進科学表記法であり、両方の部分は2の補数で格納される。
浮動小数点数表現の各部分と、それぞれの役割にマッチさせよ。
難易度 2/5 · 140 コイン + 今日初回完了時に小ボーナス付与
値 = mantissa × 2^指数;正規化は精度を最大化する;お金計算では丸め誤差を避けるために固定小数点数/BCDを使用する。
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.
ある浮動小数点数は mantissa 10110000 と指数 00000011 を持つ。この十進数の値はいくつか?
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
mantissa は1で始まるので負である:−1 + 1/4 + 1/8 = −0.625。これを 2^3 に掛けると −5.0 となる。正の値として読むことが一般的な誤りである。
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.
正規化分数と2の累乗で表すと、2.5 = 0.101 x 2^__ 。指数を答えよ。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
2.5 は二進数で 10.1 であり、小数点を2つ左にずらすと 0.101 になるため、指数は2、mantissa は 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.
浮動小数点数の正規化
正規化の手順を踏む。mantissa の先頭の不要なゼロを削除するためにシフトし、それに合わせて指数を調整することで、値は同じまま但しすべてのビットが有効性(精度)に使われるようになる。
浮動小数点数を正規化すると:
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
正規化はmantissaをシフトして最初の有効ビットを小数点の直後に配置し、すべてのビットが情報を担うようにして、値は変化しない。
浮動小数点数の正規化について正しいものをすべて選択せよ。
難易度 2/5 · 140 コイン + 今日初回完了時に小ボーナス付与
正規化は表現のみを変え、値は変わらない。指数を調整することがそれを保証している。
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.
ビット割り当ての変更と、それに対する影響をマッチさせよ。
難易度 2/5 · 140 コイン + 今日初回完了時に小ボーナス付与
ワードサイズは固定されているため、精度と範囲はトレードオフの関係にある;オーバーフローとアンダーフローは、指数フィールドが両端で使い切られることである。
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 は二進数で正確に表すことができない(無限小数のため)、ため、コンピュータ上で 0.1 + 0.2 を計算しても正確に 0.3 にはならない。
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
微小な近似誤差が蓄積するため、お金計算には固定小数点数やBCDを使用し、浮動小数点数は使わない。
正確なお金計算には以下のものを使用すべきである:
難易度 1/5 · 100 コイン + 今日初回完了時に小ボーナス付与
通貨の計算には浮動小数点の丸め誤差が許容できません。固定小数点やBCDでは、小数値を正確に格納できます。
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