How can I convert the number 123.45678 * 10^-22 to the IEEE 745 single-precision floating point representation? Can you show me the steps?
Asked
Active
Viewed 1,786 times
2
-
See http://stackoverflow.com/questions/3448777/how-to-represent-0-1-in-floating-point-arithmetic-and-decimal/3448855#3448855 – paxdiablo Nov 25 '11 at 14:53
1 Answers
2
Basically you want binary scientific notation. That is, you want your number to be of the form 2α, and you need to split α into its integral and its fractional part, α = k + β, with β < 1 and k ∈ ℤ.
To find α, take logarithms: α = log2123.45678 − 22 log210.
The integral part of the exponent, k, is stored in the exponent field of the IEEE float (after adjusting by the bias), and the fractional part 2β is stored in the mantissa (omitting the leading 1).

Kerrek SB
- 464,522
- 92
- 875
- 1,084