rotateLeft

rotateLeft(integer x, integer s) → integer rotated

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

The rotation covers all 64 bits, sign bit included. A rotation by 64 positions gives back x*, and a negative *s rotates to the right: rotateLeft(x, -s) is equivalent to rotateRight(x, s).

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