CIE AS & A Level Computer Science, section 13.3 (Floating-point numbers, representation and manipulation)
Floating-point form
A real number is stored as a mantissa (the significant digits) and an exponent (the power of 2 it is multiplied by).
Both are stored in two's complement. The mantissa is a fixed-point fraction with the binary point after the first bit, so the first bit is the sign (and has value for a negative number). The examples here use an 8-bit mantissa and a 4-bit exponent.
Converting binary to denary
Mantissa 01011000, exponent 0011.
- Mantissa: .
- Exponent: .
- Value: .
The exponent moves the binary point right if positive and left if negative.
Negative numbers
A negative mantissa begins with 1 and the first bit has place value . For 10101000:
.
To make a negative number, find the two's complement of the positive mantissa: invert the bits and add 1. For : 01011000 becomes 10101000.
Converting denary to binary
Convert :
- In binary, .
- Write it as .
- Mantissa
01011000and exponent0010.
Effect of the bits
More bits for the mantissa give greater precision; more bits for the exponent give a greater range.
Common mistake: forgetting that a mantissa has the binary point after the first bit, and that a leading 1 means a negative value. Also, when the exponent is negative, shift the point to the left.
Exam tip: show each step: the mantissa value, the exponent value, then the multiplication. Write the final answer with the correct sign.
Check yourself
What is stored in the exponent?
The power of 2 by which the mantissa is multiplied, which sets the position of the binary point.
What is the value of mantissa `01100000` with exponent `0001`?
, so .
Which gives greater precision, more mantissa bits or more exponent bits?
More mantissa bits.