Real numbers

Real numbers are numbers that include fractions/values after the decimal point.

For example, 123.75 is a real number. This type of number is also known as a floating point number.

All floating point numbers are stored by a computer system using a mantissa and an exponent.

The following example is used to illustrate the role of the mantissa and the exponent. It does not fully reflect the computer's method for storing real numbers but gives the general idea.

The number 123.75 can be represented using mathematical scientific notation as:

1.2375 x 102 = 123.75

Multiplying by ten to the power of two (102) moves the values up two places (or the decimal point down two places) so that the number 123 is before the decimal point, while the number 75 now comes immediately after the decimal point. In this example the mantissa is 1.2375 and the exponent is 2. Generally you can think of this as:

M X 10E

To represent the same value in binary, apply the following rules:

Represent the number 123.75 as:

64321684210.50.25
111101111

64 + 32 + 16 + 8 + 2 + 1 + 0.5 + 0.25 = 123.75

The number created in binary is the mantissa:

111101111

To understand the exponent, place the decimal point after the most significant bit of the mantissa. The most significant bit is the left most bit.

curriculum-key-fact
The computer will not store the actual decimal point as part of the floating point number but it is used here for illustrative purposes.

1.11101111

To calculate the exponent, it is necessary to determine how many places the decimal point would need to move to give the correct number. In this case the decimal point would need to move six places to the right:

1.11101111 - Decimal point must move six places to accurately represent 123.75

Determining the exponent when using floating point representation. Top row - 64, 32, 16, 8, 4, 2, 1, point, 0.5, 0.25. Bottom row - 1, 1, 1, 1, 0, 1, 1, point, 1, 1

So the exponent for our number is 6. In binary, the number six is:

Determining the exponent when using floating point representation. Top row 4, 2, 1 Bottom row 1, 1, 0

As 4 + 2 = 6

In order to represent 123.75 the mantissa would be 111101111 and the exponent would be 110. This can be thought of as:

M X 2E (where M repersents the mantissa and E represents the exponent)

1.11101111 x 2110

There will always be a trade-off between accuracy and range when using floating point notation, as there will always be a set number of bits allocated to storing real numbers:

  • increasing the number of bits devoted to the mantissa will improve the accuracy of a floating point number
  • increasing the number of bits devoted to the exponent will increase the range of numbers that can be held