title: How to store double - endian independent
body: <p>Despite the fact that big-endian computers are not very widely used, I want to store the double datatype in an independant format.</p>
  
  <p>For int, this is really simple, since bit shifts make that very convenient.</p>
  
  <pre><code>int number;
  int size=sizeof(number);
  char bytes[size];
  
  for (int i=0; i&lt;size; ++i)
      bytes[size-1-i] = (number &gt;&gt; 8*i) &amp; 0xFF;
  </code></pre>
  
  <p>This code snipet stores the number in big endian format, despite the machine it is being run on. <strong>What is the most elegant way</strong> to do this for double?</p>