Floating point representation

A-Level Computer Science · Floating Point, Compression and Software Development

Why fixed point is not enough

A fixed point number puts the binary point in a set position, so the range and the precision are both fixed. Floating point splits the number into a mantissa (the significant digits) and an exponent (how far to move the point), which lets the same number of bits cover a far wider range.

$\text{Value}=\text{mantissa}\times2^{\text{exponent}}$

Both parts are two's complement

The mantissa and the exponent are each held in two's complement, so both can be negative. The binary point sits immediately after the first bit of the mantissa, which is the sign bit.

Normalisation — the rule to memorise

A normalised number has its first two mantissa bits different: a positive number starts $0.1\ldots$ and a negative number starts $1.0\ldots$

Two reasons it is required. First, without it the same value has many representations ($0.1100\times2^3$ and $0.0110\times2^4$ are the same number), so comparison becomes unreliable. Second, unnormalised numbers waste leading bits that carry no information, which loses precision.

The trade-off inside a fixed word length

Give more bits to the mantissa and you gain precision but lose range; give more to the exponent and the reverse happens. That trade-off is a favourite exam question, and the answer is always that the total is fixed so one gains at the other's expense.

Errors

Overflow: the number is too large for the exponent field. Underflow: too small, so it rounds towards zero. Rounding error: many decimal fractions such as $0.1$ have no exact binary representation, so a stored value differs slightly from the intended one. That is why financial software does not test two floating point values for exact equality.

So dau phay dong — chuan hoa la bat buoc011000000011PHAN DINH TRI (8 bit)SO MU (4 bit)0.1100000 = 0,750011 = 3Gia tri = 0,75 x 2^3 = 6CHUAN HOA: hai bit dau cua dinh tri phai KHAC NHAUso duong bat dau 01… · so am bat dau 10…Khong chuan hoa thi mot so co nhieu cach viet va mat do chinh xac
Remembering one sentence is enough for most normalization questions: the first two bits of the mantissa must differ — $01$ if positive, $10$ if negative.

Worked example: conversion and normalization

A system uses an $8$-bit mantissa and a $4$-bit exponent, both in two's complement.

(a) Calculate the decimal value of 0101 0000 0010.
(b) Represent $-2.5$ in normalized form.
(c) Is the number 0001 1000 0100 normalized? If not, normalize it.

Solution

(a) Mantissa $=0.1010000$; the binary point is right after the first bit.

The first bit is $0$, so this is a positive number. Mantissa value $=\frac12+\frac18=0.5+0.125=0.625$.

Exponent $=0010=2$.

Value $=0.625\times2^2=0.625\times4=\mathbf{2.5}$

(b) Represent $-2.5$.

Step 1: write $2.5$ in binary as $10.1$.

Step 2: normalize for the POSITIVE number first — move the binary point $2$ places to the left: $0.101\times2^2$, i.e. mantissa $01010000$ and exponent $0010$. (This is exactly the result of part a.)

Step 3: take the two's complement of the MANTISSA to get the negative number. Invert the bits of $01010000$ to get $10101111$, add $1$ to get $10110000$. The exponent stays $0010$.

Result: 1011 0000 0010

Normalization check: the first two bits are $1$ and $0$ — different ✓, the correct form for a normalized negative number.

Note: take the two's complement of the mantissa only; do NOT touch the exponent. Taking the two's complement of both parts is a very common mistake.

(c) Mantissa $=0001 1000$, i.e. $0.0011000$. The first two bits are $0$ and $0$ — the same, so it is NOT normalized.

Move the binary point $2$ places to the left so that the second bit becomes $1$: the mantissa becomes $01100000$. Each time the mantissa is shifted left by one place the exponent must DECREASE by $1$ so the value does not change, so the exponent $=4-2=2$, i.e. $0010$.

Normalized result: 0110 0000 0010

Check that the value is unchanged: originally $0.1875\times2^4=3$; after normalization $0.75\times2^2=3$ ✓. This check is essential — normalization changes only HOW the number is written, not its value.

Common mistake

Shifting the mantissa left but increasing the exponent (or shifting right but decreasing). Shifting LEFT makes the mantissa bigger, so the exponent must DECREASE to compensate. A sure way to check: calculate the decimal value before and after — if they differ, you have the sign wrong.

Key takeaway

Value $=$ mantissa $\times2^{\text{exponent}}$, both parts in two's complement. Normalized means the first two bits of the mantissa differ. More mantissa bits means more precision but a narrower range. And always check against the decimal value.

← Artificial intelligence and its consequences · All A-Level Computer Science lessons · Practice A-Level Computer Science questions (free, instant scoring) · Data compression and encryption →