# Floating point representation

Consider the following two 8-bit floating-point representations based on the IEEE floating point format. The most significant bit represents the sign bit.

Format A:

There are $$k=3$$ exponent bits. The exponent bias is 3. There are $$n=4$$ fraction bits.

Format B:

There are $$k=4$$ exponent bits. The exponent bias is 7. There are $$n=3$$ fraction bits.

Convert the bit pattern $$0101 1110_2$$ represented in Format A to Format B. Show your steps.

So we know the formulae: $$E = \text{Exp} - \text{Bias}$$ and $$V = (-1)^sM2^E$$ The first bit is the sign bit $$s=0$$. Therefore the number is positive.

The next three bits $$101$$ are the exponent bits. We convert $$101$$ to decimal and get 5. We are given the exponent bias 3. Then $$E = 5 - 3 = 2$$.

Now we should figure out the mantissa $$M$$ of the scientific notation. There are 4 fraction bits. We multiply each fraction bit in $$1110$$ by 2 to the powers of -1, -2, -3, and -4 respectively and we add them all up to find the mantissa. In this case we get $$\frac{7}{8}$$.

Using formula of the value, we have $$(-1)^0 \cdot \frac{7}{8} \cdot 2^2 = 3.5$$. This number is for format A. Now I proceed with format B.

The next four bits are the exponent bits $$1011$$. We convert $$1011$$ to decimal and get 11. We are given the exponent bias 7. Then $$E = 11 - 7 = 4$$.

Now we should figure out the mantissa $$M$$ of the scientific notation. There are 3 fraction bits. We multiply each fraction bit in $$110$$ by 2 to the powers of -1, -2, and -3 respectively and we add them all up to find the mantissa. In this case we get $$\frac{3}{4}$$.

Using formula of the value, we have $$(-1)^0 \cdot \frac{3}{4} \cdot 2^4 = 12$$

Could you please confirm with me whether my solutions are correct?

I see $2$ mistakes here. In the first number you should be reading $$(-1)^s2^{e-B}\left(\color{red}{1}+\frac M{16}\right)=(-1)^02^{5-3}\left(1+\frac{14}{16}\right)=7.5=x$$ You forgot about the implicit leading $1$ bit in $\text{IEEE-754}$ binary floating point formats. The fraction $\frac{14}{16}$ is there because the mantissa was $1110_2=14$ and there are $4$ bits in the mantissa and $2^4=16$. Now, the second mistake is that the question didn't ask you to decode the original input according to the rules of format B, but rather to convert the value we just got to format B. Thus $$x=7.5=(-1)^s2^{e-7}\left(1+\frac M8\right)$$ (The denominator of $8$ because there are $3$ mantissa bits and $2^3=8$.) Since $x>0$, $s=0$ and since $2^2\le x<8$, $e-B=2=e-7$ so $e=9$ then $$1+\frac M8=\frac x{2^{e-B}}=\frac x{2^2}=\frac {15}8=1+\frac78$$ So $M=7$ and we have $x=[s]\,[e]\,[M]=0\,1001\,111$