Section 4.6
4 Data Representation
4.6 Floating Point Binary Numbers
With floating point numbers we store a mantissa and an exponent.
Example
7,800,000
becomes 0.78 × 107.
The mantissa holds the digitsand the exponent determines the point where the
fractional point goes.
Binary
Positive Mantissa
0110 1000 0000 0011 = 0.1101 × 210112
Negative Mantissa
The mantissa is always written in Two's Complement form.
Negative Exponents
The exponent can also be negative as it is in Two's Complement form.
If the exponent's left hand bit is a 1 then, when converting the exponent to
denary, the mantissa's bit pattern is shifted right.
The precision of the floating representation depends on how many digits can be
stored in the mantissa.
In order to get the most accurate representation for a given number of digits in
the mantissa the number is written with no leading zeros.
Example
0.0101 × 2100000 would be written as
0.101 × 2101111.
For a positive mantissa in normalised form the first two bits will always be
0.1.
Example
Normalise the number: 0 000110101 000010 (10-bit mantissa, 6-bit exponent)
Step 1
Put in the assumed binary point and convert the exponent to denary.
|
0
|
.
|
0
|
0
|
0
|
1
|
1
|
0
|
1
|
0
|
1
|
|
Exponent = 0000102 = 210
|
Step 2
Remembering that the overall value of the number must not change:
|
|
- Shift the mantissa bit pattern three places to the left to make it start 0.1.
|
0
|
.
|
1
|
1
|
0
|
1
|
0
|
1
|
0
|
0
|
0
|
- Subtract three from the exponent. Then convert it to binary.
|
2 - 3 = -1
-1010 = 1111112
|
The answer is: 0 110101000 111111
The first two bits of such numbers is always 1.0
To normalise a negative mantissa shift the mantissa left until the second bit is
zero and subtract as necessary from the exponent.
Example
Normalise the number: 1 111100100 000011 (10-bit mantissa, 6-bit exponent)
Step 1
Put in the assumed binary point and convert the exponent to denary.
|
1
|
.
|
1
|
1
|
1
|
1
|
0
|
0
|
1
|
0
|
0
|
|
Exponent = 0000112 = 310
|
Step 2
Remembering that the overall value of the number must not change:
|
|
- Shift the mantissa bit pattern four places to the left to make it start 1.0.
|
1
|
.
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0
|
- Subtract four from the exponent. Then convert it to binary.
|
3 - 4 = -1
-1010 = 1111112
|
With negative numbers with a magnitude greater than one it is better to
normalise the equivalent positive number and carry out Two's Complement.