1
$\begingroup$

The Problem: What value does the hexadecimal number x55544552 represent in data type IEEE floating point?

My Work:
    I first wrote out that hexadecimal number in binary and got

0101 0101 0101 0100 0100 0101 0101 0010

   Now I have my three different sections, the sign, 0, the exponent 10101010 - 127, or 170 - 127, 43, and the fraction portion 101 0100 0100 0101 0101 0010, or 5522770.

    Now I can write out my IEEE floating representation as
    1.552270 $*$ 2 $^{43}$
To simplify that expression, I decided to move the decimal point 23 slots to the right(the whole exponent proportion) and got
   (1 101 0100 0100 0101 0101 0010) * 2 $^{20}$) or 13911378 * 2$^{20}$.

To me, all my math made sense. When I checked my answer on Hex to IEEE Float, everything matched up but I couldn't figure out this part on the web application.

The web application has a specified section called fraction which represents the fraction of the floating point representation. In binary, the fraction is 1 .10101000100010101010010 but in decimal, the web application says the fraction is 1.6583655. When I converted 10101000100010101010010 to decimal, I got 5522770. Shouldn't the fraction decimal representation be 1.5522770 or am I missing something?

$\endgroup$
6
$\begingroup$

No, that's not how binary fractions work. A decimal such as $0.13$ represents $$0.13_{\mathrm{dec}} = 1\times 10^{-1} + 3\times10^{-2} = \frac{13}{100}\,.$$

Similarly, a binary fraction such as $0.1101$ represents $$0.1101_{\mathrm{bin}} = 1\times 2^{-1} + 1\times 2^{-2} + 0\times 2^{-3} + 1\times2^{-4} = \frac{13}{16}\,.$$ $1101_{\mathrm{bin}} = 13_{\mathrm{dec}}$ but $$0.1101_{\mathrm{bin}} = \frac{13}{16}\neq\frac{13}{100}=0.13_{\mathrm{dec}}\,.$$

Another way to see that you can't convert fractions into binary by forgetting that they're fractions is to note that $0.3=0.30$, but $3\neq 30$. So it can't possibly be that you convert $0.3$ in decimal to binary by saying "$3$ in binary is $11$, so $0.3$ in binary is $0.11$", since $0.3=0.30$ in decimal, so they should be equal in binary, too. But $30$ in binary is $11110$.

$\endgroup$
  • $\begingroup$ but isn't 0.11 in binary 1*2^-1 + 1*2^-2 which would be 0.75 decimal, not 0.3? $\endgroup$ – committedandroider Apr 11 '15 at 7:00
  • $\begingroup$ Exactly. As I said, "it can't possibly be that... 0.3 in binary is 0.11". $\endgroup$ – David Richerby Apr 11 '15 at 8:59

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.