Low level bit hacks

I came across a fascinating article on Peteris Krumins blog using boolean operators to perform handy low-level bit hacks.
Most people are used to just using AND and OR operators on integers, but this article goes into much more detail, explaining good – and fast – ways to manipulate integers at a bit level.

  • Check if the integer is even or odd.
  • Test if the n-th bit is set.
  • Set the n-th bit.
  • Unset the n-th bit.
    And many more. It is well worth it to go and Introduction to Low-Level Bit Hacks.

Post a Comment

Please do not post any spam link in the comment box😊

Previous Post Next Post

Blog ads

CodeGuru