Bitoperation Hacks

Various bit operation hacks


  • Compute the minimum (min) or maximum (max) of two integers without branching
  • Determining if an integer is a power of 2
  • Reverse the bits in a byte with 3 operations (64-bit multiply and modulus division):

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License