title: breaking up double precision numbers in UDP transfer in C/C++
body: <p>My program currently sends and receives UDP packets, and breaks them up in 16 bit chunks when it receives them in order to process the incoming data. Part of that incoming data is two double precision numbers (64 bits on my machine). How can I recombine the 16 bit chunks into a double precision format? They're sent to me in that format but I've found that I cannot recombine by OR-ing together, shift bits, etc. but I can only receive them 16 bits at a time. Any idea?</p>
  
  <p>so an incoming packet I receive will have a 64bit double precision number, but it gets read 16 bits at a time: 0x9080 0x1145 0x42AF 0x45F3 - I need to assemble those back to a double precision number. </p>
  
  <p>This is what I've tried so far:
  "in_data" is a 16 bit pointer to my incoming UDP packet...</p>
  
  <pre><code>        double cal1 = 0;
          double cal2 = 0;
  
          for (int i = 0; i &lt; 4; i++)     
          {
              in_data++;
              cal1 |= *in_data;
              if (i &lt; 3) cal1 &lt;&lt; 16;
          }
  
          for (int i = 0; i &lt; 4; i++) 
          {
              in_data++;  
              cal2 |= *in_data;
              if (i &lt; 3) cal2 &lt;&lt; 16;
          }
  </code></pre>
  
  <p>I realize this code is incorrect, but I had to try it before I learned it.</p>