brewersfan1976

swap_adjacent_bits.rb

Sep 25th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.09 KB | None | 0 0
  1. def swapAdjacentBits(n)
  2.     return ((n & 0x5555555555) << 1) | ((n & 0xAAAAAAAAAAA) >> 1)
  3. end
Advertisement
Add Comment
Please, Sign In to add comment