Skip to content

Instantly share code, notes, and snippets.

@iwilbert
Created August 6, 2014 20:23
Show Gist options
  • Save iwilbert/a4e99864f471aa41f899 to your computer and use it in GitHub Desktop.
Save iwilbert/a4e99864f471aa41f899 to your computer and use it in GitHub Desktop.
public int swapBits(int num) {
return (num & 0x55555555) << 1 | (num & 0xAAAAAAAA) >> 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment