Question related to Single-precision floating-point format

binary

  • What number does the following word stand for?

    $$\color{red}{1}\;\;\;\;\color{blue}{10000101}\;\;\;\;11110010011110100000000$$

Where the red one is the sign (it's called the sign bit which determines the sign of the number), the blue binary number is the Exponent, and the other bits are significand precision.

Based on this link I tried to use the following formula:

$$\text{Value}=\left(-1\right)^{\operatorname{sign}}\cdot2^{\left(e-127\right)}\cdot\left(1+\sum_{i=1}^{23}b_{23-i}\ \cdot2^{-i}\right)$$

$$\text{Value}=$$$$\left(-1\right)^{\color{red}{1}}\cdot2^{\left(\color{blue}{133}-127\right)}\cdot\left(1+2^{-1}+2^{-2}+2^{-3}+2^{-4}+2^{-7}+2^{-10}+2^{-11}+2^{-12}+2^{-13}+2^{-15}\right)$$$$=-124.619140625$$

is that right?

Best Answer

In the scripture: $$\color{red}{1}\;\;\;\;\color{blue}{10000101}\;\;\;\;11110010011110100000000$$ there are three different parts. In particular, the exponent is a natural number, so you hav to convert it from binary. The general rule to do this is: $$S=\sum_{i=0}^{N-1}2^i\cdot B_i$$ where $i=0$ means that you have to start from the right side of the binary number and $B_i$ is the $i-$term of the sequence of lenght $N$.

With this clarification, your formula becomes: $$V=\left(-1\right)^{\operatorname{sign}}\cdot2^{\left(\sum_{i=0}^{N-1}2^i\cdot B_i-127\right)}\cdot\left(1+\sum_{i=1}^{23}B_{23-i}\ \cdot2^{-i}\right)$$