Created
May 14, 2012 07:45
-
-
Save bknarendra/2692520 to your computer and use it in GitHub Desktop.
CoderCharts:Bits Manipulation
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
import java.io.*; | |
import java.util.*; | |
public class bits_manipulation | |
{ | |
public static void main(String[] args) throws Exception | |
{ | |
Scanner sc=new Scanner(new File(args[0])); | |
long a,res=0;int x,i=0; | |
while(sc.hasNext()) | |
{ | |
a=sc.nextLong(); | |
res=((a&0xaaaaaaaa)>>1)|((a&0x55555555)<<1); | |
System.out.println(res); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment