FLOAT value representation issue?

207 Views Asked by At

Im learning how the mantisse and exponent are working in the float representation

Ivve managed to catch the idea from here

however i have a problem analyzing a value.

from this picture : enter image description here

please look at line #7 (at the right side).

they wrote :

2^(-126)  = 1.18*10^(-38)

how did they do this conversion ?

can you please specify the steps for me to future convertion ? (like this)

1

There are 1 best solutions below

2
On BEST ANSWER

$$2^k = (10^{\log_{10}(2)})^k = 10^{\lfloor \log_{10}(2) \cdot k \rfloor + \varepsilon} = 10^{\varepsilon} \times 10^{\lfloor \log_{10}(2) \cdot k \rfloor} $$

where $\lfloor \cdot \rfloor$ means round to $-\infty$ and $\varepsilon \in [0, 1)$ is the remaining fractional part of the exponent. Then $10^{\varepsilon} \in [1, 10)$. For $k= -126$ you get $\log_{10}(2) \cdot -126 \approx -37.9298$ and so

$$2^{-126} \approx 10^{0.0702} \times 10^{-38} \approx 1.175 \times 10^{-38}.$$