Last active
February 22, 2016 04:30
-
-
Save thmain/500e09876f48ae22c1a7 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 BinaryRotate { | |
public int rotateBinary(int number){ | |
int res = 0; | |
while(number>0){ | |
res=res<<1; | |
res = res|(number & 1); | |
number=number>>1; | |
} | |
return res; | |
} | |
public static void main(String args[]){ | |
int x =30; | |
BinaryRotate b = new BinaryRotate(); | |
System.out.println("Binary rotation of "+ x + " is : " + b.rotateBinary(x)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment