intToZigZag method

int intToZigZag(
  1. int n
)

Implementation

int intToZigZag(int n) {
  return (n << 1) ^ (n >> 31);
}