rotateRight

rotateRight(integer x, integer s) → integer rotated

Returns the number obtained by rotating the 64 bits of the integer x* by *s positions to the right: the bits that leave at the bottom come back in at the top. Unlike the >> shift, no bit is lost. The original number is not modified.

The rotation covers all 64 bits, sign bit included: rotateRight(1, 1) sends bit 0 to position 63 and therefore returns a negative number. A rotation by 64 positions gives back x*, and a negative *s rotates to the left: rotateRight(x, -s) is equivalent to rotateLeft(x, s).

rotateRight(2, 1)    // 1
rotateRight(44, 2)   // 11: 101100 becomes 1011
rotateRight(1, 1)    // -9223372036854775808: bit 0 lands on the sign bit
rotateRight(1, 64)   // 1: full turn
rotateRight(1, -1)   // 2: rotation to the left
Math.rotateRight(2, 1)   // 1
Math.rotateRight(44, 2)  // 11: 101100 becomes 1011
Math.rotateRight(1, 1)   // -9223372036854775808: bit 0 lands on the sign bit
Math.rotateRight(1, 64)  // 1: full turn
Math.rotateRight(2, 1)   # 1
Math.rotateRight(44, 2)  # 11: 101100 becomes 1011
Math.rotateRight(1, 1)   # -9223372036854775808: bit 0 lands on the sign bit
Math.rotateRight(1, 64)  # 1: full turn
Parameters
Return
Note