Binary floating-point representation of 0.1

3k Views Asked by At

If $b=10$ and $p=3$, then 0.1 is represented as $1.00 × 1/10$. If $b=2$ and $p=24$, then 0.1 cannot be represented exactly, but is approximately

$$1.10011001100110011001101 × 1/2^4$$ Why do we divide by $2^4=16$ here?

2

There are 2 best solutions below

0
On BEST ANSWER

The binary representation of $1/10$ is actually $0.000110011001100\ldots$, but since this is "floating point" we write this as $1.10011001100\ldots \times 2^{-4}$, just as in decimal floating point we would write $0.000123$ as $1.23 \times 10^{-4}$. Each shift of the binary "decimal" point by one place corresponds to a factor of $2$.

0
On

How much is $1.10011001100110011001101_{\text{two}}$?

It's more than $1$. In fact it's clearly greater than $\frac32$.

And in any case it's quite a bit bigger than $0.1_{\text{ten}}$, which is just $\frac{1}{10}$.

So you have to divide by something to get $\frac{1}{10}$ from $1.10011001100110011001101_{\text{two}}$. What power of two would be sufficient?