Why fixed point runs out
Fixed-point representation puts the binary point at an agreed position — say eight bits before and eight after. It is simple and exact for the values it covers, but the range is fixed: those eight fractional bits cannot represent anything smaller than 1/256, and the whole part cannot exceed 255.
Floating point solves this the way scientific notation does. Instead of fixing the point, it stores where the point goes alongside the digits. A number becomes a mantissa — the significant digits — and an exponent saying how far to shift the point.
The trade-off is unavoidable and is the point of the topic. For a fixed total number of bits, giving more to the exponent widens the range but leaves fewer for the mantissa, reducing precision. You cannot have both.
- mantissa
- the significant digitsnormalised to sit just after the point
- exponent
- the shifthow many places to move the binary point
- two's complement
- the signed formatused for both parts at this level
Normalisation, and why it is required
The same value can be written many ways: 0.0101 × 2³ and 0.101 × 2² are the same number. Leaving that choice open wastes mantissa bits on leading zeros, which is precision thrown away, and it makes comparing two numbers awkward.
Normalisation fixes a single canonical form. The rule is stated in terms of the first two bits, which differ according to the sign, and it is worth memorising in exactly that form.
A positive normalised mantissa begins 0.1 — sign bit 0, then a 1. A negative normalised mantissa begins 1.0 — sign bit 1, then a 0. In both cases the first two bits must differ, and that is the quickest test.
- 0.1…
- positive normalisedsign 0, then a 1
- 1.0…
- negative normalisedsign 1, then a 0
- left shift
- multiplies the mantissa by 2compensated by decreasing the exponent
Normalise the floating-point number with mantissa 0.0011010 and exponent 0110 (both two's complement).
- Check the first two bits: 0.0 — they are the same, so it is not normalised.A positive number must begin 0.1 to be normalised.
- Shift the mantissa left one place: 0.011010, and decrease the exponent by 1 to 0101.Shifting left doubles the mantissa, so the exponent must fall by one to keep the value unchanged.
- First two bits are now 0.0 still — shift again: 0.110100, exponent 0100.Repeat until the leading bits differ.
- The mantissa now begins 0.1, so it is normalised. Mantissa 0.110100, exponent 0100.Two shifts were needed, so the exponent dropped by two from 0110 to 0100.
Mantissa 0.110100, exponent 0100
Floating point is base-2 scientific notation. The same reasoning that lets a decimal number be written as digits plus a power of ten applies here with powers of two — and the same fixed budget of digits limits the precision.
Shift left, exponent down
The direction trips people constantly. Shifting the mantissa left multiplies it by two, so the exponent must go down by one to leave the value unchanged. If you find yourself increasing the exponent while shifting left, the value has been multiplied by four rather than left alone.
Why 0.1 cannot be stored exactly
In binary, a fraction terminates only if its denominator is a power of two. One half, one quarter and three eighths are all exact. One tenth is not — 0.1 in binary is 0.0001100110011… repeating forever, exactly as one third is 0.333… in decimal.
Since only a fixed number of mantissa bits are available, the sequence must be cut short, and the stored value is very slightly wrong. This is why 0.1 + 0.2 does not print as 0.3 in most languages — the tiny errors accumulate and become visible.
The practical consequence is a rule worth carrying into any programming: never test floating-point values for exact equality. Test whether the difference is smaller than some small tolerance instead. And for money, use integer counts of the smallest unit rather than floating point at all.
Consequences to state in an exam
- Any value whose denominator is not a power of two recurs in binary and must be truncated.
- Rounding errors accumulate through repeated calculation.
- Never compare floating-point values with
=; compare the difference with a tolerance. - Store currency as an integer number of the smallest unit to avoid the problem entirely.
- More mantissa bits reduce but never eliminate the error.
- Overflow is a value too large for the exponent; underflow is one too small to represent.
Converting a stored number back to decimal
The reverse task — given a mantissa and exponent, state the decimal value — is asked at least as often as normalising, and it has a fixed method worth rehearsing.
Read the exponent first, remembering it is in two's complement so a leading 1 means it is negative. That tells you how far to move the binary point. Then read the mantissa, again in two's complement, with the point after the sign bit. Move the point by the exponent and evaluate the resulting binary fraction.
For a negative mantissa, the safest route is to negate it first — invert every bit and add one — evaluate the positive value, then apply the minus sign at the end. Trying to read place values directly from a two's complement fraction is where most errors happen.
A number has mantissa 0.1101 and exponent 0011. State its decimal value.
- The exponent 0011 is positive: +3. So the binary point moves three places right.A positive exponent makes the value larger; a leading 0 confirms it is positive in two's complement.
- The mantissa begins 0.1, so it is positive and normalised. Moving the point: 0.1101 becomes 110.1.Shifting the point right by three places is the same as multiplying by 2³.
- Evaluate 110.1 in binary: 4 + 2 + 0 + 0.5.Place values left of the point are 4, 2, 1; the first place right of it is ½.
- The value is 6.5.A quick check: the mantissa is a bit over 0.8, and 0.8 × 8 = 6.6, so 6.5 is the right order.
6.5
Place values on both sides of the point
Left of the binary point the place values double outwards — 1, 2, 4, 8. Right of it they halve — ½, ¼, ⅛, 1/16. Writing those headings above the digits before evaluating takes a few seconds and removes almost every arithmetic slip in this topic.