encodeZigZag64 function
ZigZag-encodes a signed 64-bit integer.
Same principle as encodeZigZag32 but uses a 63-bit arithmetic shift to handle the full 64-bit signed range.
Formula: (n << 1) ^ (n >> 63)
Implementation
int encodeZigZag64(int n) {
return (n << 1) ^ (n >> 63);
}