title: convert int[2] to long
body: <p>I have an int[2] representation of a long int in a 32 bit machine and want to convert it to long on 64bit machine. is there a safe architecture independent way of doing this conversion?</p>
  
  <p>The source machine is 32bit and an int is 32bits. Destination machine is 64bit and the long long type is definitely 64bits.</p>
  
  <p>can I do the following? </p>
  
  <pre><code>long i;
  int j[2];
  #ifdef LITTLEENDIAN
  j[1] = *(int*)(&amp;i);
  j[0] = *(((int*)(&amp;i))+1)
  #else
  j[0] = *(int*)(&amp;i);
  j[1] = *(((int*)(&amp;i))+1)
  #endif
  </code></pre>
  
  <p>If the above is incorrect, then what is the best and safest way for this? I am sure this would have been asked previously, but I didn't find a clean answer.</p>
  
  <p>Thanks</p>