title: C++ htonll and back
body: <p>I have found the following code which is capable of converting an int64_t to network byte order. Now I need the opposite code, such that network byte order is converted back to my little endian machine. 
  The code is this. </p>
  
  <pre><code>int64_t decode(void* value){
      int64_t vv = *((int64_t*) value);
      int num = 42;
      if(*(char *)&amp;num == 42) //test big/little endian
          return (((uint64)htonl(vv)) &lt;&lt; 32) + htonl(vv &gt;&gt; 32);
      else 
          return vv;
  }
  </code></pre>
  
  <p>Thanks a lot!</p>