0
$\begingroup$

The IEEE floating point number format is defined as

$$s\underbrace{c_1\dots c_m}_\text{exponent}\underbrace{f_1\dots f_n}_\text{fraction}\text{ (*)}$$

with $s, c_i, f_j$ being either $1$ or $0$. The corresponding decimal representations are as follows: $$c = \sum\limits_{i=1}^m c_i 2^i 2^{m-i}$$ $$f=\sum\limits_{i=1}^n f_i 2^{-i}$$

Let $\xi$ be the corresponding decimal representation of (*). Then $$\xi = (-1)^s 2^{c-(2^{m-1}-1)}(1+f)$$

In the case of single precision, $m=8$ and $n=23$ and in double precision these are $m=11$ and $n=52$.

I want to find how many double precision floating point numbers there are between any two single precision floating point numbers.

Here's my approach to solving this:

Let $x_1 := 2^{c_{sp}-(2^7-1)}(1+f_{sp})$, $x_2=2^{c_{dp}-(2^{10}-1)}(1+f_{dp})$, where $c_{sp}=(11111110)_2=254$ and $c_{dp}=(00011111110)_2$ are corresponding single and double precision representations (here I'm taking the largest exponent for single precision and the corresponding exponent in double precision).

Now, let $d := |x_{2,sp}-x_{1,sp}|$ be the difference between two adjacent floating point numbers, where $x_{1,sp}:=2^{c_{sp}-(2^7-1)}(1-f_{1, sp})$ and $x_{2,sp}:=2^{c_{sp}-(2^7-1)}(1-f_{2, sp})$ and $f_{2,sp}=(0.\underbrace{11\dots1}_\text{23 times})_2$, $f_{1,sp}=f_{2,sp}-\epsilon=(0.11\dots10)_2$. The corresponding double precision representations are $f_{2,dp}=0.\underbrace{11\dots1}_\text{23 times}\underbrace{0\dots 0}_\text{52-23 times}$, $f_{1,dp}=0.\underbrace{11\dots1}_\text{22 times}\underbrace{0\dots 0}_\text{52-22 times}$.

Then, clearly, the double precision representation has 29 additional places after the binary (fractional) point. Which means that there are $2^{29}-1$, that is $n_{dp}-n_{sp}$, numbers in double precision between any two single precision numbers.

Do you think this is correct?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.