Convert floating point number 1864.78 to binary and IEEE format
<p>I've been trying to convert the value of the S&amp;P 500 which today is 1864.78 to how it would be represented in IEEE single precision format in memory.</p>

<p>Converting the left of the decimal (1864) is easy.</p>

<p>11101001000.</p>

<p>But how do I get the binary representation of the decimal (.78)?  I tried using the technique but it produces many numbers over the 8 bit exponent IEEE format:</p>

<p>.78*2=1.56  1</p>

<p>.56*2=1.12  1</p>

<p>.12*2=.24   0</p>

<p>.24*2=.48   0</p>

<p>.48*2=.96   0</p>

<p>.96*2=1.92  1</p>

<p>.92*2=1.84  1</p>

<p>.84*2=1.68  1</p>

<p>.68*2=1.36  1</p>

<p>.36*2=.72   0</p>

<p>.72*2=1.44  1</p>

<p>.44*2=.88   1 (rounded up because now we have 23 total bits)</p>

<p>11101001000.110001111011 = 23 bits for mantissa</p>

<p>Add 0 for sign</p>

<p>0 11101001000.110001111011</p>

<p>Now I need to move the decimal over 10 places</p>

<p>1.1101001000110001111011 x 2^10 exponent is 10 now</p>

<p>add a 0 bit to make full mantissa 23 bits</p>

<p>1.11010010001100011110110</p>

<p>exponent is 10 so 10 + 127 = 137</p>

<p>which is equal to 10001001</p>

<p>so 0 10001001 11010010001100011110110 which is a 32 bit number.</p>

<p>Does this look like a decent approach?  I tested the value and writing this question I was actually able to work through it on my own.</p>

<p>Testing the decimal FP with this.
<a href="http://www.h-schmidt.net/FloatConverter/IEEE754.html" rel="nofollow">http://www.h-schmidt.net/FloatConverter/IEEE754.html</a></p>