Skip to content

Instantly share code, notes, and snippets.

@jyhjuzi
Created July 25, 2014 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jyhjuzi/70a45225c8a06007fb89 to your computer and use it in GitHub Desktop.
Save jyhjuzi/70a45225c8a06007fb89 to your computer and use it in GitHub Desktop.
public class Q5_6{
public static void main(String[] args){
int test = 0b01011100110100010101001;
System.out.println(Integer.toBinaryString(swap(test)));
}
static int swap(int input){
return ((input & 0x55555555) << 1) | ((input & 0xaaaaaaaa)>>1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment