yphastos
8/1/2017 - 7:14 PM

swap Adjacent Bits

swap Adjacent Bits

int swapAdjacentBits(int n)
{
  return ((n & 0x2AAAAAAA) >> 1) | ((n & 0x55555555) << 1) ;
}