How to convert numbers from 32 bit single precision IEEE 754 binary floating point standard to decimal system in base 10
Follow the steps below to convert a number from 32 bit single precision IEEE 754 binary floating point representation to base 10 decimal system:
- 1. Identify the three elements that make up the binary representation of the number:
First bit (leftmost) indicates the sign, 1 = negative, 0 = pozitive.
The next 8 bits contain the exponent.
The last 23 bits contain the mantissa. - 2. Convert the exponent, that is allways a positive integer, from binary (base 2) to decimal (base 10).
- 3. Adjust the exponent, subtract the excess bits, 2(8 - 1) - 1 = 127, that is due to the 8 bit excess/bias notation.
- 4. Convert the mantissa, that represents the number's fractional part (the excess beyond the number's integer part, comma delimited), from binary (base 2) to decimal (base 10).
- 5. Put all the numbers into expression to calculate the single precision floating point decimal value:
(-1)Sign × (1 + Mantissa) × 2(Exponent adjusted)
Example: convert the number 1 - 1000 0001 - 100 0001 0000 0010 0000 0000 from 32 bit single precision IEEE 754 binary floating point system to base 10 decimal system (float):
- 1. Identify the elements that make up the binary representation of the number:
First bit (leftmost) indicates the sign, 1 = negative, 0 = pozitive.
The next 8 bits contain the exponent: 1000 0001
The last 23 bits contain the mantissa: 100 0001 0000 0010 0000 0000 - 2. Convert the exponent, that is allways a positive integer, from binary (base 2) to decimal (base 10): 1000 0001(2) =
1 × 27 + 0 × 26 + 0 × 25 + 0 × 24 + 0 × 23 + 0 × 22 + 0 × 21 + 1 × 20 =
128 + 0 + 0 + 0 + 0 + 0 + 0 + 1 =
128 + 1 =
129(10) - 3. Adjust the exponent, subtract the excess bits, 2(8 - 1) - 1 = 127, that is due to the 8 bit excess/bias notation:
Exponent adjusted = 129 - 127 = 2 - 4. Convert the mantissa, that represents the number's fractional part (the excess beyond the number's integer part, comma delimited), from binary (base 2) to decimal (base 10): 100 0001 0000 0010 0000 0000(2) =
1 × 2-1 + 0 × 2-2 + 0 × 2-3 + 0 × 2-4 + 0 × 2-5 + 0 × 2-6 + 1 × 2-7 + 0 × 2-8 + 0 × 2-9 + 0 × 2-10 + 0 × 2-11 + 0 × 2-12 + 0 × 2-13 + 1 × 2-14 + 0 × 2-15 + 0 × 2-16 + 0 × 2-17 + 0 × 2-18 + 0 × 2-19 + 0 × 2-20 + 0 × 2-21 + 0 × 2-22 + 0 × 2-23 =
0.5 + 0 + 0 + 0 + 0 + 0 + 0.007 812 5 + 0 + 0 + 0 + 0 + 0 + 0 + 0.000 061 035 156 25 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 =
0.5 + 0.007 812 5 + 0.000 061 035 156 25 =
0.507 873 535 156 25(10) - 5. Put all the numbers into expression to calculate the single precision floating point decimal value: (-1)Sign × (1 + Mantissa) × 2(Exponent adjusted) =
(-1)1 × (1 + 0.507 873 535 156 25) × 22 =
-1.507 873 535 156 25 × 22 =
-6.031 494 140 625 1 - 1000 0001 - 100 0001 0000 0010 0000 0000 converted from 32 bit single precision IEEE 754 binary floating point representation to decimal number (float) in decimal system (in base 10) = -6.031 494 140 625(10)