Mantissa and exponent
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.
- 1This 12-bit format uses an 8-bit mantissa and a 4-bit exponent, both in two’s complement.
- 2The radix (base) is 2 and is implied rather than stored.
- 3The 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.
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.
| Field | What a leading 1 means |
|---|---|
| Mantissa | The stored number is negative. |
| Exponent | The scale factor is less than 1: divide by a power of two. |
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?
- 1M = ½ + ¼ = 0.75, E = 2: 0.75 × 2² = 3
- 2the mantissa: its first bit has weight −1
- 3-1: −8 + 4 + 2 + 1
Binary floating point to denary
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.
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.
- Decode the mantissaM=−1 + 1/8 + 1/16=−0.8125
- Decode the exponentE=0(−8) + 0(4) + 1(2) + 1(1)=3
- Apply the scale factorValue=−0.8125 × 2³=−6.5
- Answer−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.
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.
- 1M = −1 + ¼ = −0.75, E = 2: −0.75 × 4 = -3
- 2M = 0.5, E = −1: 0.5 ÷ 2 = 0.25
- 3M = ½ + ¼ + ⅛ = 0.875, E = 1: 0.875 × 2 = 1.75
Denary to binary floating point
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.
Store 5.75 using an 8-bit mantissa and a 4-bit exponent, both in two’s complement. Give a normalised representation.
- Convert the whole and fractional parts5=101₂; 0.75 = 0.11₂5.75=0101.11₂
- Put the point after the sign bit0101.11₂=0.10111₂ × 2³
- Fill the specified fieldsMantissa: 01011100Exponent: 0011
- Answer01011100 | 0011
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.
Check: (−1 + ⅛ + 1/16) × 8 = −6.5. Changing only the first bit of 01101000 would give −0.1875 × 8 = −1.5, not −6.5.
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.
- 13.5 = 11.1₂ = 0.111₂ × 2²: 01110000 | 0010
- 2complement 01110000 → 10010000; exponent stays: 10010000 | 0010
- 30.375 = 0.011₂ = 0.11₂ × 2⁻¹: 01100000 | 1111
Normalising a floating-point number
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.
Negative: stop at 10
Shift until the first two bits differ. The value under every row stays −6.5.
Positive: stop at 01
0.1796875 × 25 = 5.75
↓ shift mantissa left once; subtract 1 from exponent
0.359375 × 24 = 5.75
↓ shift mantissa left once; subtract 1 from exponent
0.71875 × 23 = 5.75
First two mantissa bits differ: normalised.
Negative: stop at 10
-0.203125 × 25 = -6.5
↓ shift mantissa left once; subtract 1 from exponent
-0.40625 × 24 = -6.5
↓ shift mantissa left once; subtract 1 from exponent
-0.8125 × 23 = -6.5
First two mantissa bits differ: normalised.
One shift in the mantissa needs one change in the exponent
- 1Each left shift doubles the mantissa’s value. Fill newly vacated right-hand positions with 0.
- 2Subtracting 1 from the exponent halves the scale factor, so the product is unchanged.
- Normalising cannot recover bits already discarded by rounding.
- Zero has no leading 01 or 10 and is handled separately.
1 Normalise 00011000 | 0100.
2 Normalise 11110000 | 0011.
3 Why must the exponent fall by 1 for each left shift?
- 1two shifts: 01100000 | 0010; both are 3
- 2three shifts: 10000000 | 0000; both are -1
- 3a left shift doubles the mantissa; one less in the exponent halves the scale, so the value stays the same
Precision and range
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 format | Mantissa | Exponent |
|---|---|---|
| A | 8 bits | 4 bits: −8 to 7 |
| B | 9 bits | 3 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.
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 limit | A: 8 + 4 bits | B: 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.
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(63/64) × 2¹⁵ = 32256
- 2½ × 2⁻¹⁶ = 1/131072
- 3range: a longer exponent reaches further, but a shorter mantissa gives coarser spacing
Approximation and rounding errors
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.
| Multiply | Next bit | Remainder | What happens | |
|---|---|---|---|---|
| step 1 | 0.3 × 2 = 0.6 | 0 | 0.6 | whole part 0 is the next bit; carry on with 0.6 |
| whole part 0 is the next bit; carry on with 0.6 | ||||
| step 2 | 0.6 × 2 = 1.2 | 1 | 0.2 | whole part 1 is the next bit; carry on with 0.2 |
| whole part 1 is the next bit; carry on with 0.2 | ||||
| step 3 | 0.2 × 2 = 0.4 | 0 | 0.4 | whole part 0 is the next bit; carry on with 0.4 |
| whole part 0 is the next bit; carry on with 0.4 | ||||
| step 4 | 0.4 × 2 = 0.8 | 0 | 0.8 | whole part 0 is the next bit; carry on with 0.8 |
| whole part 0 is the next bit; carry on with 0.8 | ||||
| step 5 | 0.8 × 2 = 1.6 | 1 | 0.6 | 0.6 again: the digits repeat |
| 0.6 again: the digits repeat | ||||
| Multiply | Next bit | Remainder |
|---|---|---|
| 0.3 × 2 = 0.6 | 0 | 0.6 |
| 0.6 × 2 = 1.2 | 1 | 0.2 |
| 0.2 × 2 = 0.4 | 0 | 0.4 |
| 0.4 × 2 = 0.8 | 0 | 0.8 |
| 0.8 × 2 = 1.6 | 1 | 0.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.
| Method in A | Stored fields | Value |
|---|---|---|
| Truncate | 01001100 | 1111 | 0.296875 |
| Round to nearest | 01001101 | 1111 | 0.30078125 |
A small error can accumulate
One tiny error rarely matters. Forty of them added together can.
- 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.
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?
- 10.00011…₂
- 20.3 − 0.296875 = 0.003125
- 3its binary digits repeat for ever, so any fixed length must cut them off
Overflow and underflow
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.
The blue bands are what A can store. The edges of the positive band, as stored fields:
| Positive boundary | Fields | Value |
|---|---|---|
| Largest | 01111111 | 0111 | (127/128) × 2⁷ = 127 |
| Smallest normalised | 01000000 | 1000 | ½ × 2⁻⁸ = 1/512 |
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.
- Find the mathematical result100 + 40=140
- Find the exponent needed140=0.546875 × 2⁸
- Check the exponent limit8 > 7
- AnswerOverflow: 140 is outside the positive range.
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.
- 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.
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?
- 1overflow: 130 > 127
- 2underflow: 1/1024 is nonzero but below 1/512
- 3stored: −120 is above −128 (10001000 | 0111)
Selecting a floating-point format
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.
| Format | Mantissa/exponent | Largest positive |
|---|---|---|
| A | 8 / 4 bits | 127 |
| B | 9 / 3 bits | 7.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.
Follow the last 1-bit: its weight, 1/256, times 2³ is exactly the 1/32 step the controller needs.
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.
| Requirement | Choice | Decisive reason |
|---|---|---|
| Multiples of 1/32, from 4 to 6.5 | B | Fine enough spacing within its range. |
| Whole numbers, from 0 to 80 | A | Sufficient range while keeping each integer exact. |
Steps for checking any format
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.
- 12⁵/2⁷ = 1/4
- 2A: 20 is inside its range and its spacing at exponent 5 is 1/4; B overflows above 7.96875
- 3B: at exponent 2 its spacing is 1/64; A’s is 1/32, too coarse