title: Lua - Handling 64 bits number on 32 bit lua compiler
body: <p>Currently I am trying to decode data (using lua). Data I have is 64 bit hexadecimal (big endian).</p>
  
  <p>That specific number needs to be converted to little endian. Beside that other bitwise operations are going to be applied later based on the internal logic.</p>
  
  <p>Now, initially I thought that things are going to be easy, having in mind that I can use <a href="http://bitop.luajit.org/api.html" rel="noreferrer">bitop</a> and simply apply any bitwise operations I would like to.</p>
  
  <p>Now, unfortunately, I have (<strong>and please make a note that I am not able to change this</strong>), 32 bit lua compiler, hence, I am not simply able to use these operations.</p>
  
  <p>There are 2 questions which I would like to ask:</p>
  
  <ul>
  <li><p>If i have hex</p>
  
  <p><code>800A000000000000</code> how can I use 32 bitwise operations (specifically in this case operations like bit.bswap, bit.rshift, bit.lshift from the library i shared above) on this
  hexadecimal number? Is it possible to split this number on 2 parts,
  and then apply operations on each of them and then merge them
  together again? If that is the case, how?</p></li>
  <li>Do you have any good reference (like a good book) which I can use to
  familiarize myself with algorithms and what I can do and what I
  cannot when we are talking about bitwise operations (expecially
  representing huge numbers using multiple small chunks )</li>
  </ul>
  
  <p>Prior asking this question, I found and read other references to the same subject, but all of them are more related with specific cases (which is hard to understand unless you are familiar with the subject):</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/3725291/lua-64-bit-transitioning-issue">lua 64-bit transitioning issue</a> </li>
  <li><a href="https://stackoverflow.com/questions/3104722/does-lua-make-use-of-64-bit-integers">Does Lua make use of
      64-bit integers?</a></li>
  <li><a href="https://stackoverflow.com/questions/48093429/determine-whether-lua-compiler-runs-32-or-64-bit">Determine whether Lua compiler runs 32 or
      64 bit</a></li>
  <li><a href="https://stackoverflow.com/questions/35488855/comparing-signed-64-bit-number-using-32-bit-bitwise-operations-in-lua">Comparing signed 64 bit number using 32 bit bitwise
      operations in Lua</a></li>
  </ol>