Note to self
Code, cooking, catman
Friday, July 27, 2007
reverse an integer (in a crazy way)
public static int reverse(int i) {
i = (i & 0x55555555) <<>>> 1) & 0x55555555;
i = (i & 0x33333333) <<>>> 2) & 0x33333333;
i = (i & 0x0f0f0f0f) <<>>> 4) & 0x0f0f0f0f;
i = (i <<>>> 8) & 0xff00) | (i >>> 24);
return i;
}
compare this with my
really old post
about the same problem
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment