Floating-point numbers, representation and manipulation

Computer Science A2 · Data Representation. The idea in plain words, the rules to remember, the mistake to avoid and a worked example, written and checked by Mega Lecture.

Test this topic freeAll Computer Science A2 topics

The idea

A real number is stored in two parts: a mantissa, which holds the digits, and an exponent, which says how many places to move the binary point. Value = mantissa × 2exponent. Both parts are in two's complement, and the binary point of the mantissa comes after its first bit.

A number is normalised when the first two bits of the mantissa are different. This gives one form for each value and the greatest precision for the bits available.

Only a limited set of values can be stored exactly. Many fractions, such as 0.1, have no exact binary form, so the stored value is an approximation and rounding errors appear in calculations.

In simpler words

A computer stores a real number in two parts. The mantissa holds the digits. The exponent says how far to move the binary point. Both use two's complement. A number is normalised when the first two bits of the mantissa are different. This gives the best accuracy. Many fractions, like 0.1, cannot be stored exactly, so small rounding errors appear.

An everyday comparison

Floating point is like writing 3.2 × 105 in science. The 3.2 holds the digits and the power of ten says where the point goes. Normalising is like always writing one digit before the point, so each number has one form. The comparison stops working because computers use base 2, and the first mantissa bit is worth −1, not a normal digit.

Rules to remember

Common mistake

Students read a negative mantissa as if it were positive. The first bit is worth −1, so 1.0100000 is −1 + 1/4 = −0.75, not 1.25 or −0.25.

In the exam

Show your working in steps. First write the mantissa place values: −1, 1/2, 1/4, 1/8 and so on, and add the values of the 1 bits. Then convert the exponent from two's complement. Then state value = mantissa × 2exponent and give the answer. To normalise, shift the mantissa left until the first two bits differ, and subtract 1 from the exponent for each shift. When asked about the split of bits, say more mantissa bits give precision and more exponent bits give range.

Worked example

A number is stored with an 8-bit two's complement mantissa (binary point after the first bit) and a 4-bit two's complement exponent. Mantissa 10100000, exponent 0011. What is the denary value?

  1. Mantissa 1.0100000 = −1 + 1/4 = −0.75.
  2. Exponent 0011 = 3, so multiply by 23 = 8.
  3. −0.75 × 8 = −6.

Answer: −6 (the mantissa starts 10, so the number is normalised).

Ask about this

Type what you are stuck on. The helper finds the explanation, worked examples and the notes to read, free and instant.

Keep going

← File organisation and accessProtocols →Take a Computer Science A2 test