Expand description
Zigzag encoding is an alternative way of encoding negative numbers.
In zigzag encoding, the least-significant bit is used to represent the sign.
Counting up alternates between non-negative and negative numbers as the LSB
switches between 0 and 1.
§Example
// to allow the use of the `Zigzag::zigzag` function
use varint_rs::zigzag::Zigzag;
// create an i32 set to `300`
let number: i32 = 300;
// encode the i32 into a u32
let encoded: u32 = number.zigzag();
// decode the u32 into an i32
let decoded: i32 = encoded.zigzag();Traits§
- Zigzag
- The
Zigzagtrait enables zigzag encoding for a type.