2

I have a question like this:

Show how the number $-12.75$D is stored in the computer's storage using IEEE754 32-bit single precision format. You are required to show your conversion steps clearly.

My answer is:

$-12.75\mathrm{D}=-1100.11\mathrm{B}$
normalization: $-1.10011\times 2^3$
$E(D)=127+3=130\mathrm{D}$
$E(B)=130\mathrm{D}=1000\ 0010\mathrm{B}$
sign: negative: $1$
$IEEE 754(SP)=1\ 10000010\ 10011....\mathrm{B}$

Is it correct?

JRN
  • 6,691
Bilis
  • 125

1 Answers1

5

Your final version is correct. $\require{enclose} \def\xD{{}_{10}} \def\xB{{}_{2}} $

Given any real number, if its representation in basis $b$ ($2 \le b \le 10$) is given by a string $???$ consists solely of digits and at most one decimal point, we will use the notation $???_{b}$ to label it.

Since $$ -12.75\xD = -(2^3 + 2^2 + 0 + 0 + 2^{-1} + 2^{-2}) = -1100.11\xB = -1.10011\xB \times 2^3$$ the sign bit $S$ is $1$, exponent $E$ is $3\xD$ and the mantissa $M$ is $1.10011\xB$.

For IEEE754 single precision numbers, we use

  • $1$ bit for sign, $S = 1 \mapsto \color{red}{\enclose{box}{1}}$
  • $8$ bit for exponent but encoded with an offset of $127$. So $$E = 3\xD \mapsto 3\xD + 127\xD = 130\xD = (2^7 + 2^1) = 1000 0010\xB \mapsto \color{green}{\enclose{box}{1000\;0010}} $$
  • $24$ bit for mantissa but the leading bit is implicit and only $23$ bits are stored. $$M = 1.10011\xB \mapsto 1\color{blue}{\enclose{box}{100\;1100\;0000\;0000\;0000\;0000}}$$

Under IEEE754, $-12.75\xD$ will be encoded as

$$\color{red}{\enclose{box}{1}}\!-\!\color{green}{\enclose{box}{1000\;0010}}\!-\!\color{blue}{\enclose{box}{100\;1100\;0000\;0000\;0000\;0000}}$$

There are several single precision converter on the web. The one I used for reference is this. Play with it and it will help you understand how floating points numbers are encoded in this format.

achille hui
  • 125,323