rotateLeft

fun Int.Companion.rotateLeft(i: Int, distance: Int): Int

Returns the value obtained by rotating the two's complement binary representation of the specified int value left by the specified number of bits. (Bits shifted out of the left hand, or high-order, side reenter on the right, or low-order.)

Note that left rotation with a negative distance is equivalent to right rotation: rotateLeft(val, -distance) == rotateRight(val, distance). Note also that rotation by any multiple of 32 is a no-op, so all but the last five bits of the rotation distance can be ignored, even if the distance is negative: rotateLeft(val, distance) == rotateLeft(val, distance & 0x1F).

Return

the value obtained by rotating the two's complement binary representation of the specified int value left by the specified number of bits.

Since

1.5

Parameters

i

the value whose bits are to be rotated left

distance

the number of bit positions to rotate left


fun Long.Companion.rotateLeft(i: Long, distance: Int): Long

Returns the value obtained by rotating the two's complement binary representation of the specified long value left by the specified number of bits. (Bits shifted out of the left hand, or high-order, side reenter on the right, or low-order.)

Note that left rotation with a negative distance is equivalent to right rotation: rotateLeft(val, -distance) == rotateRight(val, distance). Note also that rotation by any multiple of 64 is a no-op, so all but the last six bits of the rotation distance can be ignored, even if the distance is negative: rotateLeft(val, distance) == rotateLeft(val, distance & 0x3F).

Return

the value obtained by rotating the two's complement binary representation of the specified long value left by the specified number of bits.

Since

1.5

Parameters

i

the value whose bits are to be rotated left

distance

the number of bit positions to rotate left