rotateLeft method

int rotateLeft(
  1. int n,
  2. int count
)

implementation of a left rotation of an integer by count places.

Implementation

int rotateLeft(int n, int count) {
  assert(count >= 0 && count < 32);
  if (count == 0) return n;
  return (n << count) |
      ((n >= 0) ? n >> (32 - count) : ~(~n >> (32 - count)));
}