ZEncode implements zig-zag encoding The sign will be encoded as the least significant bit in the result ZEncode(x) < abs(x)*2
(x int64)
| 4 | // The sign will be encoded as the least significant bit in the result |
| 5 | // ZEncode(x) < abs(x)*2 |
| 6 | func ZEncode(x int64) uint64 { |
| 7 | return uint64((x << 1) ^ (x >> 63)) |
| 8 | } |
| 9 | |
| 10 | // ZDecode is the inverse operation of ZEncode |
| 11 | // ZDecode(ZEncode(x)) == x |