Skip to content

Instantly share code, notes, and snippets.

@bknarendra
Created May 14, 2012 07:45
Show Gist options
  • Save bknarendra/2692520 to your computer and use it in GitHub Desktop.
Save bknarendra/2692520 to your computer and use it in GitHub Desktop.
CoderCharts:Bits Manipulation
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