Float to Decimal Conversion
The Conversion Procedure
The rules for converting a floating point number into decimal are
simply to reverse of the decimal to floating point conversion:
- If the original number is in hex, convert it to binary.
- Separate into the sign, exponent, and mantissa fields.
- Extract the mantissa from the mantissa field, and restore the
leading one. You may also omit the trailing zeros.
- Extract the exponent from the exponent field, and
subtract the bias to recover the actual exponent of two.
As before, the bias is 2k−1 − 1, where k is the
number of bits in the exponent field, giving 3 for the 8-bit format
and 127 for the 32-bit.
- De-normalize the number: move the binary point so the exponent is
0, and the value of the number remains unchanged.
- Convert the binary value
to decimal. This is done just as with binary integers, but the place
values right of the binary point are fractions.
- Set the sign of the decimal number according to the sign bit
of the original floating point number:
make it negative for 1; leave positive for 0.
If the binary exponent is very large or small, you can convert the
mantissa directly to decimal without de-normalizing. Then use a calculator to
raise two to the exponent, and perform
the multiplication. This will give an approximate answer, but is
sufficient in most cases.
Examples Using The Conversion Procedure
- Convert the 8-bit floating point number e7 (in hex) to decimal.
- Convert: e716 = 111001112.
- Seprate: 11100111
- Mantissa: 1.0111
- Exponent: 1102 = 610; 6 − 3 = 3.
- De-normalize: 1.01112 × 23 =
1011.1
- Convert:
Exponents |
23 | | 22 | | 21 | | 20 |
|
2-1 |
Place Values |
8 | | 4 | | 2 | | 1 |
|
0.5 |
Bits |
1 | | 0 | | 1 | | 1 |
. |
1 |
Value |
8 |
|
|
+ |
2 |
+ |
1 |
+ |
0.5 |
= |
11.5 |
- Sign: negative.
Result: e7 is -11.5
- Convert the 8-bit floating point number 26 (in hex)
to decimal.
- Convert and separate: 2616 =
00100110 2
- Exponent: 0102 = 210;
2 − 3 = -1.
- Denormalize: 1.0112 × 2-1 =
0.1011.
- Convert:
Exponents |
20 |
|
2-1 |
| 2-2 |
| 2-3 |
| 2-4 |
Place Values |
1 |
|
0.5 |
| 0.25 |
| 0.125 |
| 0.0625 |
Bits |
0 |
. |
1 | | 0 | | 1 | | 1 |
Value |
|
|
0.5 |
|
|
+ |
0.125 |
+ |
0.0625 |
= |
0.6875 |
- Sign: positive
Result: 26 is 0.6875.
- Convert the 8-bit floating point number d3 (in hex)
to decimal.
- Convert and separate: d316 =
11010011 2
- Exponent: 1012 = 510;
5 − 3 = 2.
- Denormalize: 1.00112 × 22 =
100.11.
- Convert:
Exponents |
22 | | 21 | | 20 |
|
2-1 |
| 2-2 |
Place Values |
4 | | 2 | | 1 |
|
0.5 |
| 0.25 |
Bits |
1 | | 0 | | 0 |
. |
1 | | 1 |
Value |
4 |
|
|
|
|
+ |
0.5 |
+ |
0.25 |
= |
4.75 |
- Sign: negative
Result: d3 is -4.75.
- Convert the 32-bit floating point number 44361000 (in hex)
to decimal.
- Convert and separate: 4436100016 =
01000100001101100001000000000000 2
- Exponent: 100010002 = 13610;
136 − 127 = 9.
- Denormalize: 1.011011000012 × 29 =
1011011000.01.
- Convert:
Exponents |
29 | | 28 | | 27 | | 26 | | 25 | | 24 | | 23 | | 22 | | 21 | | 20 |
|
2-1 |
| 2-2 |
Place Values |
512 | | 256 | | 128 | | 64 | | 32 | | 16 | | 8 | | 4 | | 2 | | 1 |
|
0.5 |
| 0.25 |
Bits |
1 | | 0 | | 1 | | 1 | | 0 | | 1 | | 1 | | 0 | | 0 | | 0 |
. |
0 | | 1 |
Value |
512 |
|
|
+ |
128 |
+ |
64 |
|
|
+ |
16 |
+ |
8 |
|
|
|
|
|
|
|
|
+ |
0.25 |
= |
728.25 |
- Sign: positive
Result: 44361000 is 728.25.
- Convert the 32-bit floating point number be580000 (in hex)
to decimal.
- Convert and separate: be58000016 =
10111110010110000000000000000000 2
- Exponent: 011111002 = 12410;
124 − 127 = -3.
- Denormalize: 1.10112 × 2-3 =
0.0011011.
- Convert:
Exponents |
20 |
|
2-1 |
| 2-2 |
| 2-3 |
| 2-4 |
| 2-5 |
| 2-6 |
| 2-7 |
Place Values |
1 |
|
0.5 |
| 0.25 |
| 0.125 |
| 0.0625 |
| 0.03125 |
| 0.015625 |
| 0.0078125 |
Bits |
0 |
. |
0 | | 0 | | 1 | | 1 | | 0 | | 1 | | 1 |
Value |
|
|
|
|
|
|
0.125 |
+ |
0.0625 |
|
|
+ |
0.015625 |
+ |
0.0078125 |
= |
0.2109375 |
- Sign: negative
Result: be580000 is -0.2109375.
- Convert the 32-bit floating point number a3358000 (in hex)
to decimal.
- Convert and separate: a335800016 =
10100011001101011000000000000000 2
- Exponent: 010001102 = 7010;
70 − 127 = -57.
- Since the exponent is far from zero,
convert the original (normalized) mantissa:
Exponents |
20 |
|
2-1 |
| 2-2 |
| 2-3 |
| 2-4 |
| 2-5 |
| 2-6 |
| 2-7 |
| 2-8 |
Place Values |
1 |
|
0.5 |
| 0.25 |
| 0.125 |
| 0.0625 |
| 0.03125 |
| 0.015625 |
| 0.0078125 |
| 0.00390625 |
Bits |
1 |
. |
0 | | 1 | | 1 | | 0 | | 1 | | 0 | | 1 | | 1 |
Value |
1 |
|
|
+ |
0.25 |
+ |
0.125 |
|
|
+ |
0.03125 |
|
|
+ |
0.0078125 |
+ |
0.00390625 |
= |
1.41796875 |
- Use calculator to find 1.41796875
× 2-57. You should get
something like 9.83913471531 × 10-18
.
- Sign: negative
Result: a3358000 is about -9.83913471531 × 10-18
.
- Convert the 32-bit floating point number 76650000 (in hex)
to decimal.
- Convert and separate: 7665000016 =
01110110011001010000000000000000 2
- Exponent: 111011002 = 23610;
236 − 127 = 109.
- Since the exponent is far from zero,
convert the original (normalized) mantissa:
Exponents |
20 |
|
2-1 |
| 2-2 |
| 2-3 |
| 2-4 |
| 2-5 |
| 2-6 |
| 2-7 |
Place Values |
1 |
|
0.5 |
| 0.25 |
| 0.125 |
| 0.0625 |
| 0.03125 |
| 0.015625 |
| 0.0078125 |
Bits |
1 |
. |
1 | | 1 | | 0 | | 0 | | 1 | | 0 | | 1 |
Value |
1 |
+ |
0.5 |
+ |
0.25 |
|
|
|
|
+ |
0.03125 |
|
|
+ |
0.0078125 |
= |
1.7890625 |
- Use calculator to find 1.7890625
× 2109. You should get
something like 1.16116794981 × 1033
.
- Sign: positive
Result: 76650000 is about 1.16116794981 × 1033
.