decodeZigZag function
ZigZag-decodes an unsigned integer back to its signed representation.
Reverses the mapping performed by encodeZigZag32 or encodeZigZag64: 0 → 0, 1 → -1, 2 → 1, 3 → -2, 4 → 2, …
Formula: (n >>> 1) ^ -(n & 1)
The logical right shift (>>>) drops the encoding's LSB parity flag,
while -(n & 1) produces an all-zeros or all-ones mask that restores
the original sign via XOR.
Implementation
int decodeZigZag(int n) {
return (n >>> 1) ^ -(n & 1);
}