title: How to convert an IEEE 754 single-precision binary floating-point to decimal?
body: <blockquote>
    <p>I am working on a program that needs to convert a 32-bit number into a decimal number. </p>
  </blockquote>
  
  <p>The number that I get from input is a 32 bit number represented as floating point. The first bit is the sign, the next 8 bits are the exponent, and the other 23 bits are mantissa. I am working the program in C. In input, I get that number as a <code>char[]</code> array, and after that I am making a new <code>int[]</code> array where I store the sign , the exponent and the mantissa. But, I have problem with the mantissa when I am trying to store it in some datatype, because I need to use the mantissa  as a number, not as an array: <code>formula=sign*(1+0.mantissa)*2^(exponent-127)</code>.</p>
  
  <p>Here is the code I use to store the mantissa, but still the program gets me wrong results:</p>
  
  <pre><code>double oMantissa=0;
  int counter=0;
  for(counter=0;counter&lt;23;counter++)
  {
      if(mantissa[counter]==1)
      {
          oMantissa+=mantissa[counter]*pow(10,-counter);
      }
  }
  </code></pre>
  
  <p><code>mantissa[]</code> is an <code>int</code> array where I have already converted the mantissa from a <code>char</code> array. When I get the value from <code>formula</code>, it has to be a binary number, and I have to convert it to decimal, so I will get the value of the number. Can you help me with storing the 23 bits of the mantissa? And, I mustn't use functions like <code>strtoul</code> that convert the 32-bit number directly into binary. I have to use <code>formula</code>.</p>