title: Converting a byte array to a decimal number in C++
body: <p>I'm trying to convert latitude and longitude to a byte arrayusing Java and then convert the byte array to double using C++. SO far, here's what I'm doing:</p>
  
  <p>I have a byte array of <code>{0x40,0x4a, 0x62, 0x65, 0x27, 0xa2, 0x05, 0x79}</code> which gives <strong>52.768712</strong> in JAVA. </p>
  
  <p>I'm trying to do the same thing in C++ using:</p>
  
  <pre><code>unsigned char data[8] = { 0x40,0x4a, 0x62, 0x65, 0x27, 0xa2, 0x05, 0x79};
  
   double sample;
   double conversion;
  
   copy(data, data+ sizeof(double), reinterpret_cast&lt;char*&gt;(&amp;sample));
   memcpy(&amp;conversion, data, sizeof(double));
  
   cout &lt;&lt;fixed &lt;&lt; sample &lt;&lt; endl;
   cout &lt;&lt;fixed &lt;&lt; conversion &lt;&lt; endl;
  </code></pre>
  
  <p>But this outputs </p>
  
  <pre><code>93624845218206212768416858147698568034806357864636725490778543828533000856049725637297881892477906693728822997596617150540736669122257619339758101303551253860040255473731364930515446918886205365571056786975140751691636070476504921373224351498841838203471739594278994672877568.000000
  </code></pre>
  
  <p>What am I doing wrong here?</p>