how to convert binary data to float value?
<p>For my data logger project I'm logging data to a SD card. Here I'm storing the data in binary format. I'm logging accelerometer and temp&amp;humidity sensors. I could read data byte by byte. Hence to print ADXL data (two bytes), I combine each two byte data. Hence four bytes has to be combined to get temparature data. Unfortunately for temparature I failed to print actual data. There is some conversion problem. I'm looking some help regarding how to convert data to floats.</p>

<p>Code to read and print binary to uint16_t ( accelerometer data): working</p>

<pre><code>while ((nr = fgetc(logFile)) != EOF){
         pc.printf(" \r\n %d ",nr);
          acc_con[i] = nr;
          if (i == 1){ 
          acc = (acc_con[1]&lt;&lt;8) | acc_con[0];
          pc.printf(" \r\n %i ",acc);
          i = 0;} 
          else i++; 
         }
</code></pre>

<p>Code to read and print binary to float ( temparature data): Not working</p>

<pre><code>while ((nr = fgetc(logFile)) != EOF){
         pc.printf(" \r\n %d ",nr);
           humicon[i] = nr;
           if (i == 3){
            hum = (humicon[0] &lt;&lt; 24) | (humicon[1] &lt;&lt; 16) | (humicon[2] &lt;&lt; 8) | humicon[3];
            pc.printf(" \r\n %f ",hum);
            i = 0;}
            else i++;
            }
</code></pre>

<p>The byte by byte raw data from variable nr is: 24, 58, 46, 66, and the output from variable hum is: 406466112.000000.</p>

<p>I could read humidity or temparature (floats) with fread. Unfortunatly to use fread I must know th no of bytes stored in the file.
With below code I could print floats also.
     int main() {</p>

<pre><code>int nr;
FILE *fp = fopen("/sd/PCE000.bin", "rb");
float read[1];
fread(read,sizeof(float),1,fp);
pc.printf("\r\n %f",read[0]);
  fclose(fp); 
</code></pre>

<p>}</p>

<p>I would like to know the formula for the conversion like (acc_con[1]&lt;&lt;8) | acc_con[0]. Thank you.</p>