Skip to content

Instantly share code, notes, and snippets.

@akadrac
Last active October 10, 2016 10:29
Show Gist options
  • Save akadrac/29c263ab8d518b953f4e770aa39b987e to your computer and use it in GitHub Desktop.
Save akadrac/29c263ab8d518b953f4e770aa39b987e to your computer and use it in GitHub Desktop.
Swap Adjacent Bits
function swapAdjacentBits(n) {
return (((n & 0b101010101010101010101010101010) >> 1) | ((n & 0b010101010101010101010101010101) << 1)) ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment