Lesson Objective
- Be able to represent and normalise floating point numbers.
- Know why floating point numbers are normalised and be able to normalise un-normalised floating point numbers with positive or negative mantissas.
KS3, GCSE, A-Level Computing Resources
There are two main reasons why we need to normalize floating point binary numbers:
It is the process of moving the binary point of a floating point number to provide the maximum level of precision for a given number of bits.
Example: 14.125 into a normalised two's complement floating point number with a 10 bit mantissa and a 6 bit exponent.
-16 | 8 | 4 | 2 | 1 | 1/2 | 1/4 | 1/8 | 1/16 | 1/32 | |
---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 1 | 1 | 0 | • | 0 | 0 | 1 | 0 | 0 |
8 + 4 + 2 + ⅛(0.125) = 14.125
Positive two's complement numbers most significant bit must be 0. In order to maximise precision the next most significant bit must be 1.
Place the decimal point between the first 0 and 1. Move 4 places to the left.
0 | • | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 |
The value of the exponent is 4 because it would have to be moved 4 places to the right to return to the original number.
The normalised two's complement floating point representation of 14.125 is below.
Mantissa | Exponent | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
-1 | 1/2 | 1/4 | 1/8 | 1/16 | 1/32 | 1/64 | 1/128 | 1/256 | 1/512 | -32 | 16 | 8 | 4 | 2 | 1 | |
0 | • | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
Example: -45.375 into a normalised two's complement floating point number with a 10 bit mantissa and a 6 bit exponent.
-64 | 32 | 16 | 8 | 4 | 2 | 1 | 1/2 | 1/4 | 1/8 | |
---|---|---|---|---|---|---|---|---|---|---|
1 | 0 | 1 | 0 | 0 | 1 | 0 | • | 1 | 0 | 1 |
-64 + 16 + 2 + ½(0.5) + ⅛(0.125) = -45.375
In a negative two's complement format the most significant bit must be 1.
In order to maximise precision the next most significant bit must be 0.
1 | • | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 |
We must place the decimal point between the first 1 and 0. In this case we need to move the binary point 6 places to the left.
The normalised two's complement floating point representation of -45.375 is below.
Mantissa | Exponent | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
-1 | 1/2 | 1/4 | 1/8 | 1/16 | 1/32 | 1/64 | 1/128 | 1/256 | 1/512 | -32 | 16 | 8 | 4 | 2 | 1 | |
1 | • | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 |
Example: -0.46875 into a normalised two's complement floating point number with a 10 bit mantissa and a 6 bit exponent.
-16 | 8 | 4 | 2 | 1 | 1/2 | 1/4 | 1/8 | 1/16 | 1/32 | |
---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | 1 | 1 | 1 | • | 1 | 0 | 0 | 0 | 1 |
-16 + 8 + 4 + 2 + 1 + ½(0.5) + 1/32(0.03125) = -0.46875
The decimal point between the first 1 and 0. In a negative number leading 1s can be lost so in this case we need to move the binary point 1 place to the right and lose 5 leading 1s.
1 | 1 | 1 | 1 | 1 | 1 | • | 0 | 0 | 0 | 1 |
The binary point was moved 1 place to the right so the value of the exponent is -1 because it would have to be moved 1 place to the left to return to the original number.
Final number is below:
Mantissa | Exponent | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
-1 | 1/2 | 1/4 | 1/8 | 1/16 | 1/32 | 1/64 | 1/128 | 1/256 | 1/512 | -32 | 16 | 8 | 4 | 2 | 1 | |
1 | • | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 |