Skip to content

9618 · Unit 14 · Paper 3: Advanced theory

Floating-point representation.

9618 · Unit 14 · Floating-point representation
Revisionbyexamplicity

Mantissa and exponent

§13.3 · Floating-point representation

Scientific notation writes 6 020 000 as 6.02 × 10⁶, so a huge or tiny value fits in a few digits: the digits and the scale are kept apart. A floating-point number does the same in binary, with a signed mantissa (also called a significand) for the digits and a signed exponent that scales them by a power of two.

value = mantissa × 2exponent
Mantissa · 8 bits
01011100
Exponent · 4 bits
0011
  1. 1
    This 12-bit format uses an 8-bit mantissa and a 4-bit exponent, both in two’s complement.
  2. 2
    The radix (base) is 2 and is implied rather than stored.
  3. 3
    The binary point is implied immediately after the mantissa’s sign bit; it is not stored.

The first bit has a negative weight

Add the weights printed over the 1-bits in each field, then multiply. The first bit of each field has a negative weight, −1 and −8; here both are 0.

Mantissa · 8 bits0−11½0¼1⅛11/1611/3201/6401/128binary pointM = ½ + ⅛ + 1/16 + 1/32 = 0.71875Exponent · 4 bits0−8041211E = 2 + 1 = 3Value = 0.71875 × 2³ = 5.75
−101/211/401/811/1611/3211/6401/1280
Mantissa = ½ + ⅛ + 1/16 + 1/32 = 0.71875Read the 1-bits using the fractional weights.Exponent 0011 = 2 + 1 = 3Exponent weights are −8, 4, 2, 1.Value = 0.71875 × 2³ = 5.75The exponent scales the value, not the number of stored bits.

The exponent scales the value, not the number of stored bits.

What a leading 1 means in each field

The same leading bit means something different in each field, and mixing the two up turns a small number into a negative one.

FieldWhat a leading 1 means
MantissaThe stored number is negative.
ExponentThe scale factor is less than 1: divide by a power of two.
A negative exponent does not make the number negative. Its sign comes from the mantissa.
Your turn

1 Mantissa 01100000, exponent 0010. Give the denary value.

2 Which field decides whether the number is negative?

3 What denary value does the exponent 1111 hold?

  1. 1
    M = ½ + ¼ = 0.75, E = 2: 0.75 × 2² = 3
  2. 2
    the mantissa: its first bit has weight −1
  3. 3
    -1: −8 + 4 + 2 + 1
Tick what you can do now
Practise with s26/31 Q3(b); s26/32 Q3(a)
1 / 8
9618 · Unit 14 · Floating-point representation
Revisionbyexamplicity

Binary floating point to denary

§13.3 · Floating-point representation

Reading a stored number back takes two small conversions and a multiplication. Decode each signed field, then apply the exponent. Watch the first mantissa bit: it has weight −1, not a separate minus sign in front of the remaining bits.

See every bit’s place value

Here the first mantissa bit is 1, so the sum starts at −1. Add the other 1-bits to it, then decode the exponent the same way.

Mantissa · 8 bits1−10½0¼1⅛11/1601/3201/6401/128binary pointM = −1 + ⅛ + 1/16 = −0.8125Exponent · 4 bits0−8041211E = 2 + 1 = 3Value = −0.8125 × 2³ = −6.5
Worked question

A format uses an 8-bit fractional mantissa and a 4-bit integer exponent, both in two’s complement. The mantissa is 10011000 and the exponent is 0011. Find the denary value.

  1. Decode the mantissa
    M=−1 + 1/8 + 1/16=−0.8125
  2. Decode the exponent
    E=0(−8) + 0(4) + 1(2) + 1(1)=3
  3. Apply the scale factor
    Value=−0.8125 × 2³=−6.5
  4. Answer
    −6.5
✓Check 10011000 represents signed integer −104. Divide by 128 to place the fractional point, then multiply by 8: −104 ÷ 128 × 8 = −6.5.

When the exponent is negative

A negative exponent divides instead of multiplying.

Follow the exponent: its first bit is 1, so it starts at −8 and the scale ends up below 1.

Mantissa · 8 bits0−11½0¼1⅛01/1601/3201/6401/128binary pointM = ½ + ⅛ = 0.625Exponent · 4 bits1−8141201E = −8 + 4 + 2 = -2Value = 0.625 × 2⁻² = 0.15625
Mantissa · 8 bits
01010000
Exponent · 4 bits
1110
Mantissa 0.1010000 = ½ + ⅛ = 0.625A leading 0 gives a positive mantissa.Exponent 1110 = −8 + 4 + 2 = −2Decode all four bits as a signed integer.Value = 0.625 × 2⁻² = 0.625 ÷ 4 = 0.15625Moving the point left twice gives 0.00101₂.
Your turn

1 Mantissa 10100000, exponent 0010. Give the denary value.

2 Mantissa 01000000, exponent 1111. Give the denary value.

3 Mantissa 01110000, exponent 0001. Give the denary value.

  1. 1
    M = −1 + ¼ = −0.75, E = 2: −0.75 × 4 = -3
  2. 2
    M = 0.5, E = −1: 0.5 ÷ 2 = 0.25
  3. 3
    M = ½ + ¼ + ⅛ = 0.875, E = 1: 0.875 × 2 = 1.75
Tick what you can do now
Practise with s26/31 Q3(b); s26/32 Q3(a)
2 / 8
9618 · Unit 14 · Floating-point representation
Revisionbyexamplicity

Denary to binary floating point

§13.3 · Floating-point representation

Storing a number runs the other way. Build the binary value first, then choose a mantissa and exponent that preserve it. Many pairs give the same value, so one is agreed: in a normalised nonzero value, the first two mantissa bits differ.

Move the point, count the places

The number of places the point moves left becomes the exponent.

5.75 in binary0101.11₂Move the point 3 places left, after the sign bit0.10111₂ × 2³Exponent 3 → 0011; mantissa padded to 8 bits → 01011100
Worked question

Store 5.75 using an 8-bit mantissa and a 4-bit exponent, both in two’s complement. Give a normalised representation.

  1. Convert the whole and fractional parts
    5=101₂; 0.75 = 0.11₂5.75=0101.11₂
  2. Put the point after the sign bit
    0101.11₂=0.10111₂ × 2³
  3. Fill the specified fields
    Mantissa: 01011100Exponent: 0011
  4. Answer
    01011100 | 0011
✓Check (½ + ⅛ + 1/16 + 1/32) × 8 = 5.75.

Storing a negative value

A negative value needs one more step. To store −6.5 in the same format, first write +6.5 as 0.1101000₂ × 2³.

Follow the mantissa down the three rows: invert every bit, then add 1 in the last place. Its first bit becomes 1, so the value is negative.

+6.5 mantissa01101000↓invert every bit10010111↓add 11001100010011000: −1 + ⅛ + 1/16 = −0.8125
Positive mantissa: 01101000Eight bits, including the sign.Invert: 10010111; add 1: 10011000Add 1 at the least significant stored position.Negative representation: 10011000 | 0011Leading 10 is normalised; the exponent stays 3.

Check: (−1 + ⅛ + 1/16) × 8 = −6.5. Changing only the first bit of 01101000 would give −0.1875 × 8 = −1.5, not −6.5.

Your turn

1 Store 3.5 as a normalised 8-bit mantissa and 4-bit exponent.

2 Store −3.5 in the same format.

3 Store 0.375 in the same format.

  1. 1
    3.5 = 11.1₂ = 0.111₂ × 2²: 01110000 | 0010
  2. 2
    complement 01110000 → 10010000; exponent stays: 10010000 | 0010
  3. 3
    0.375 = 0.011₂ = 0.11₂ × 2⁻¹: 01100000 | 1111
Tick what you can do now
Practise with s26/31 Q3(a); s26/33 Q5(a)
3 / 8
9618 · Unit 14 · Floating-point representation
Revisionbyexamplicity

Normalising a floating-point number

§13.3 · Floating-point representation

A mantissa such as 00011000 wastes its front bits repeating the sign. Normalisation removes these redundant leading sign bits. That gives the mantissa room to retain more significant binary digits, while the exponent preserves the value.

Positive: stop at 01

Each row down is one left shift and 1 off the exponent. The value under every row stays 5.75.

mantissaexponent0001011101010.1796875 × 2⁵ = 5.75↓ shift left once · exponent − 10010111001000.359375 × 2⁴ = 5.75↓ shift left once · exponent − 10101110000110.71875 × 2³ = 5.75 · normalised

Negative: stop at 10

Shift until the first two bits differ. The value under every row stays −6.5.

mantissaexponent111001100101−0.203125 × 2⁵ = −6.5↓ shift left once · exponent − 1110011000100−0.40625 × 2⁴ = −6.5↓ shift left once · exponent − 1100110000011−0.8125 × 2³ = −6.5 · normalised

Positive: stop at 01

Mantissa · 8 bits
00010111
Exponent · 4 bits
0101

0.1796875 × 25 = 5.75

↓ shift mantissa left once; subtract 1 from exponent

Mantissa · 8 bits
00101110
Exponent · 4 bits
0100

0.359375 × 24 = 5.75

↓ shift mantissa left once; subtract 1 from exponent

Mantissa · 8 bits
01011100
Exponent · 4 bits
0011

0.71875 × 23 = 5.75

First two mantissa bits differ: normalised.

Negative: stop at 10

Mantissa · 8 bits
11100110
Exponent · 4 bits
0101

-0.203125 × 25 = -6.5

↓ shift mantissa left once; subtract 1 from exponent

Mantissa · 8 bits
11001100
Exponent · 4 bits
0100

-0.40625 × 24 = -6.5

↓ shift mantissa left once; subtract 1 from exponent

Mantissa · 8 bits
10011000
Exponent · 4 bits
0011

-0.8125 × 23 = -6.5

First two mantissa bits differ: normalised.

One shift in the mantissa needs one change in the exponent

  1. 1
    Each left shift doubles the mantissa’s value. Fill newly vacated right-hand positions with 0.
  2. 2
    Subtracting 1 from the exponent halves the scale factor, so the product is unchanged.
For −8, 11000000 | 0100 is not normalised: −0.5 × 16 = −8. Shift once to 10000000 | 0011: −1 × 8 = −8. A negative mantissa may equal −1.
  • Normalising cannot recover bits already discarded by rounding.
  • Zero has no leading 01 or 10 and is handled separately.
Your turn

1 Normalise 00011000 | 0100.

2 Normalise 11110000 | 0011.

3 Why must the exponent fall by 1 for each left shift?

  1. 1
    two shifts: 01100000 | 0010; both are 3
  2. 2
    three shifts: 10000000 | 0000; both are -1
  3. 3
    a left shift doubles the mantissa; one less in the exponent halves the scale, so the value stays the same
Tick what you can do now
Practise with s26/31 Q3(a); s26/33 Q5(a)
4 / 8
9618 · Unit 14 · Floating-point representation
Revisionbyexamplicity

Precision and range

§13.3 · Floating-point representation

Twelve bits are shared between the two fields, so every bit given to one is taken from the other. With a fixed total of bits, a longer mantissa gives finer precision but leaves a shorter exponent and a narrower range.

A and B split the same twelve bits two ways. Keep both in view for each comparison that follows.

12-bit formatMantissaExponent
A8 bits4 bits: −8 to 7
B9 bits3 bits: −4 to 3

Compare precision at the same exponent

At exponent 0, changing the last mantissa bit changes A by 1/128 and B by 1/256. B places another representable value between each adjacent pair from A.

A: 8 mantissa bitsspacing 1/128B: 9 mantissa bitsspacing 1/2560.6250.65625

Compare the range of each format

Each limit comes from the ends of both fields: the largest mantissa with the top exponent, then the smallest normalised mantissa, ½, with the lowest.

Positive limitA: 8 + 4 bitsB: 9 + 3 bits
Largest(127/128) × 2⁷ = 127(255/256) × 2³ = 7.96875
Smallest normalised½ × 2⁻⁸ = 1/512½ × 2⁻⁴ = 1/32
  • A reaches larger magnitudes and closer to zero.
  • B represents finer differences within its range. Neither format is better for every task.
Spacing also grows with the exponent. In A it is 1/128 at exponent 0, but 2³/128 = 1/16 at exponent 3.
Your turn

1 A 12-bit format has a 7-bit mantissa and a 5-bit exponent. What is its largest positive value?

2 What is its smallest positive normalised value?

3 Compared with format A, has it gained range or precision?

  1. 1
    (63/64) × 2¹⁵ = 32256
  2. 2
    ½ × 2⁻¹⁶ = 1/131072
  3. 3
    range: a longer exponent reaches further, but a shorter mantissa gives coarser spacing
Tick what you can do now
Practise with s24/32 Q1(a); w25/33 Q2(a) (older papers: bit allocation)
5 / 8
9618 · Unit 14 · Floating-point representation
Revisionbyexamplicity

Approximation and rounding errors

§13.3 · Floating-point representation

In denary, ⅓ never ends: 0.333… goes on for ever. Some fractions that end neatly in denary, such as 0.3, behave like that in binary: they have no finite binary representation. A fixed-length mantissa must then store an approximation, even when the number is within range.

Why 0.3 cannot be stored exactly

Format A uses an 8-bit fractional mantissa and 4-bit integer exponent, both in two’s complement. For 0.3, multiply the fractional remainder by 2, record the integer part, and repeat with the new remainder.

MultiplyNext bitRemainderWhat happens
step 10.3 × 2 = 0.600.6whole part 0 is the next bit; carry on with 0.6
whole part 0 is the next bit; carry on with 0.6
step 20.6 × 2 = 1.210.2whole part 1 is the next bit; carry on with 0.2
whole part 1 is the next bit; carry on with 0.2
step 30.2 × 2 = 0.400.4whole part 0 is the next bit; carry on with 0.4
whole part 0 is the next bit; carry on with 0.4
step 40.4 × 2 = 0.800.8whole part 0 is the next bit; carry on with 0.8
whole part 0 is the next bit; carry on with 0.8
step 50.8 × 2 = 1.610.60.6 again: the digits repeat
0.6 again: the digits repeat
MultiplyNext bitRemainder
0.3 × 2 = 0.600.6
0.6 × 2 = 1.210.2
0.2 × 2 = 0.400.4
0.4 × 2 = 0.800.8
0.8 × 2 = 1.610.6: repeats

So 0.3 = 0.0100110011…₂ = 0.100110011…₂ × 2⁻¹. In format A, the first seven fractional mantissa bits are 1001100; further nonzero bits remain.

0.3 falls between two neighbouring values that A can store. Truncating keeps the lower one; rounding takes the nearer.

0.2968750.30078125exact 0.3Nearest stored value: 0.30078125
Method in AStored fieldsValue
Truncate01001100 | 11110.296875
Round to nearest01001101 | 11110.30078125

A small error can accumulate

One tiny error rarely matters. Forty of them added together can.

Rounded error = 0.30078125 − 0.3 = 0.00078125The stored value is slightly too large.40 × 0.30078125 = 12.03125; exact total = 12Assume enough accumulator precision to avoid further rounding.
  • More mantissa bits reduce this representation error; they do not make every fraction exact.
  • Keep sufficient precision during calculations and round the displayed result at the end.
Your turn

1 Multiply by 2 five times to find the first five bits after the point for 0.1.

2 How far is the truncated value 0.296875 from 0.3?

3 Why can no number of mantissa bits store 0.1 exactly?

  1. 1
    0.00011…₂
  2. 2
    0.3 − 0.296875 = 0.003125
  3. 3
    its binary digits repeat for ever, so any fixed length must cut them off
Tick what you can do now
Practise with w24/31 Q1(a) (older paper: loss of precision)
6 / 8
9618 · Unit 14 · Floating-point representation
Revisionbyexamplicity

Overflow and underflow

§13.3 · Floating-point representation

Add 100 and 40 in a format whose largest value is 127 and the answer has nowhere to go. That is overflow: a result whose magnitude is too large for the format. At the other end, underflow is a nonzero result too close to zero to be represented.

Use format A: an 8-bit fractional mantissa and 4-bit exponent, both two’s complement. Nonzero values here are normalised. Zero is stored separately; no subnormal values are used.

overflowoverflowunderflowstoredstored−12801270 < |value| < 1/512 cannot be storedNot to scale. Zero itself is stored separately.

The blue bands are what A can store. The edges of the positive band, as stored fields:

Positive boundaryFieldsValue
Largest01111111 | 0111(127/128) × 2⁷ = 127
Smallest normalised01000000 | 1000½ × 2⁻⁸ = 1/512
Worked question

In format A, calculate 100 + 40 and decide whether its result can be stored. The largest positive normalised value is 127 and the largest exponent is 7.

  1. Find the mathematical result
    100 + 40=140
  2. Find the exponent needed
    140=0.546875 × 2⁸
  3. Check the exponent limit
    8 > 7
  4. Answer
    Overflow: 140 is outside the positive range.
✓Check 140 > 127, the largest positive value.

Underflow: a result too close to zero

Divide the smallest positive value by 4: the result is not zero, but it needs an exponent A does not have.

(1/512) ÷ 4 = 1/2048 = ½ × 2⁻¹⁰Both the original value and divisor are representable.Required exponent −10 < minimum exponent −8The nonzero result is too small in magnitude: underflow.
  • Replacing that tiny result by zero loses information and can affect later calculations.
  • The negative number −6.5 is representable: being below zero is not underflow.
  • The most negative value in A is −1 × 2⁷ = −128.
Your turn

1 In format A, is 100 + 30 stored, or does it overflow?

2 In format A, (1/512) ÷ 2. Stored, or underflow?

3 In format A, −100 − 20. Stored, overflow or underflow?

  1. 1
    overflow: 130 > 127
  2. 2
    underflow: 1/1024 is nonzero but below 1/512
  3. 3
    stored: −120 is above −128 (10001000 | 0111)
Tick what you can do now
Practise with s26/32 Q3(b); s26/33 Q5(b)
7 / 8
9618 · Unit 14 · Floating-point representation
Revisionbyexamplicity

Selecting a floating-point format

§13.3 · Floating-point representation

The right format depends on the numbers it has to hold. Check range and precision separately: a format can reach the largest value yet fail to distinguish the nearby values you need.

The same two formats, A and B, now judged against what a task needs to store.

FormatMantissa/exponentLargest positive
A8 / 4 bits127
B9 / 3 bits7.96875

Check the spacing where the values will be stored

A controller must store every multiple of 1/32 from 4 to 6.5. These values use exponent 3 in both formats.

A spacing = 2³/2⁷ = 1/16Its steps skip alternate required multiples of 1/32.B spacing = 2³/2⁸ = 1/32Its steps match the required spacing, and 6.5 is within range.

Follow the last 1-bit: its weight, 1/256, times 2³ is exactly the 1/32 step the controller needs.

Mantissa · 9 bits0−11½1¼0⅛01/1601/3201/6401/12811/256binary pointM = ½ + ¼ + 1/256 = 0.75390625Exponent · 3 bits0−41211E = 2 + 1 = 3Value = 0.75390625 × 2³ = 6.03125
Mantissa · 9 bits
011000001
Exponent · 3 bits
011

In B, 011000001 | 011 stores (½ + ¼ + 1/256) × 8 = 6.03125. A cannot store that value exactly: it lies halfway between 6 and 6.0625.

When range decides the choice

For whole-number readings from 0 to 80, A has enough range and precision. At exponent 7 its spacing is 1, so it can still distinguish consecutive integers. B overflows long before 80.

RequirementChoiceDecisive reason
Multiples of 1/32, from 4 to 6.5BFine enough spacing within its range.
Whole numbers, from 0 to 80ASufficient range while keeping each integer exact.

Steps for checking any format

1
Find the signed exponent limits and the required value range.
2
Find the last mantissa-bit weight at the exponent being used.
3
Compare that spacing with the required precision; convert a boundary or troublesome value back to check.
Your turn

1 What is A’s spacing at exponent 5?

2 Values up to 20 in steps of ¼ must be stored. Choose A or B, and say why.

3 Readings from 2 to 3 in steps of 1/64 must be stored (exponent 2). Choose A or B, and say why.

  1. 1
    2⁵/2⁷ = 1/4
  2. 2
    A: 20 is inside its range and its spacing at exponent 5 is 1/4; B overflows above 7.96875
  3. 3
    B: at exponent 2 its spacing is 1/64; A’s is 1/32, too coarse
Tick what you can do now
Practise with s26/33 Q5(b); w25/33 Q2(a) (older paper: allocation trade-off)
8 / 8