ZigZag encoding that maps signed integers with a small absolute value to unsigned integers with a small (positive) values. Without this, encoding negative values using Varint would use up 9 or 10 bytes.
Declared in <folly/Varint.h>
uint64_t
encodeZigZag(int64_t val);
if x >= 0, encodeZigZag(x) == 2*x if x < 0, encodeZigZag(x) == -2*x - 1
The ZigZag-encoded unsigned value.
| Name | Description |
|---|---|
| val | The signed value to encode. |