Skip to main content

zigzag_encode

Function zigzag_encode 

Source
pub fn zigzag_encode(n: i64, type_bits: u8) -> u64
Expand description

Encode a signed integer using ZigZag encoding.

Maps signed values to unsigned: 0 -> 0, -1 -> 1, 1 -> 2, -2 -> 3, etc. type_bits is the bit width of the source type (e.g. 32 for i32, 64 for i64).