Created
August 5, 2014 00:42
-
-
Save bitcpf/8d741b6cad060a205559 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Q5_6 { | |
public static void main(String[] args){ | |
int test = 73; | |
System.out.println(Integer.toBinaryString(test)); | |
System.out.println(Integer.toBinaryString(SwapEvenOdd(test))); | |
} | |
public static int SwapEvenOdd(int n){ | |
int tempOdd = (n & 0x55555555) << 1; | |
int tempEven = (n & 0xaaaaaaaa) >> 1; | |
return tempOdd | tempEven; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment