yphastos
8/1/2017 - 7:13 PM

swap Adjacent Bits

swap Adjacent Bits

function swapAdjacentBits($n) {
  return (($n & 0b10101010101010101010101010101010) >> 1) | (($n & 0b01010101010101010101010101010101) << 1) ;
}