How do I simulate a bitwise rotation of a 64-bit (unsigned) integer in JavaScript?

Keep your 64-bit number as separate high and low partitions. To rotate left N when N < 32:

hi_rot = ((hi << N) | (lo >>> (32-N))) & (0xFFFFFFFF)

lo_rot = ((lo << N) | (hi >>> (32-N))) & (0xFFFFFFFF)

If N >= 32, then subtract 32 from N, swap hi and lo, and then do the above.


I believe so, though not the most efficient way, convert the number to a string in binary form (64-bits), use substring to move the char at the beginning and append it to the end (for left rotation) and convert the binary form back to number. I am sure you can figure out how to convert a decimal number to its binary form into a string and back.