Relates :
|
java.lang.Integer implements 32-bit rotation as: public static int rotateLeft(int i, int distance) { return (i << distance) | (i >>> -distance); } public static int rotateRight(int i, int distance) { return (i >>> distance) | (i << -distance); } x86 includes the ROL and ROR instruction that do just that, but HotSpot currently does not take advantage of them. Note that in many use cases, distance is a compile-time constant. Similarly for Long.rotateLeft() and Long.rotateRight().
|