title: How to convert integer to little-endian in a portable way
body: <p>I wonder what's the recommended way to convert integer to/from little-endian in a portable way.</p>
  
  <p>Is there any library for that?</p>
  
  <p>We can use <a href="http://linux.die.net/man/3/htonl" rel="nofollow">htonl and ntohl</a> and then do another big-endian to (from) little-endian conversion, but it's not efficient.</p>