title: Converting IEEE 754 packed bit stream into float single precision
body: <p>I have a problem with converting unsigned long to Float single precision
  Here is my problem</p>
  
  <p>I need to communicate in floating point in my program, but all my internal variables are unsigned long, So the design we decided was such that everything will remain same,(in unsigned long) and once a float needs to be given to application, i will convert to float and pass it on.</p>
  
  <p>So all the variables will have a IEEE 754 bit stream according to </p>
  
  <p><a href="http://www.h-schmidt.net/FloatConverter/" rel="nofollow">Float converter</a></p>
  
  <p>Steps i follow :</p>
  
  <ol>
  <li>I get the value in char array</li>
  <li>I take the bits and copy into a unsigned long</li>
  <li>While giving the data on function call, i typecast to float single precision.</li>
  </ol>
  
  <p>In debugger i see the same bit pattern (in buffers) for steps 1 &amp;2</p>
  
  <p>In step 3 too, i see the same binary pattern, but the value is not interpreted as a float</p>
  
  <p>Input  : 21.125</p>
  
  <ol>
  <li>Binary : 01000001101010010000000000000000</li>
  <li>Hex    : 0x41a90000</li>
  <li><p>Decimal: 1101594624 </p>
  
  <pre><code>Code:
  void ApplicationApi(void * DataPtr)
  {
  (*(float32*)((void*)DataPtr))= unsignedLong_val;
  }
  </code></pre></li>
  </ol>
  
  <p>Result in application DataPtr 
  * DataPtr = 1.101594624 * e9</p>
  
  <p>Am i missing something here or the type case worked ?</p>