Skip to main content

Module zigzag

Module zigzag 

Source
Expand description

Holds helpers for encoding and decoding numbers using the zigzag encoding.

The zigzag encoding converts signed integers to unsigned integers and vice versa.

  • Positive signed integers are multiplied by 2.
  • Negative signed integers are multiplied by -2 and 1 is subtracted.
  • The final result is then converted to an unsigned integer.

Functionsยง

zigzag_decode32
Decodes a 32-bit unsigned integer to a 32-bit signed integer using the zigzag encoding.
zigzag_decode64
Decodes a 64-bit unsigned integer to a 64-bit signed integer using the zigzag encoding.
zigzag_decode128
Decodes a 128-bit unsigned integer to a 128-bit signed integer using the zigzag encoding.
zigzag_encode32
Encodes a 32-bit signed integer to a 32-bit unsigned integer using the zigzag encoding.
zigzag_encode64
Encodes a 64-bit signed integer to a 64-bit unsigned integer using the zigzag encoding.
zigzag_encode128
Encodes a 128-bit signed integer to a 128-bit unsigned integer using the zigzag encoding.