zigzag

package
v0.0.0-...-53ff736 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(x uint64) int64

Decode decodes a zig-zag-encoded uint64 as an int64.

Input:  {…,  5,  3,  1,  0,  2,  4,  6, …}
Output: {…, -3, -2, -1,  0, +1, +2, +3, …}

func DecodeBool

func DecodeBool(x uint64) bool

DecodeBool decodes a uint64 as a bool.

Input:  {    0,    1,    2, …}
Output: {false, true, true, …}

func Encode

func Encode(x int64) uint64

Encode encodes an int64 as a zig-zag-encoded uint64.

Input:  {…, -3, -2, -1,  0, +1, +2, +3, …}
Output: {…,  5,  3,  1,  0,  2,  4,  6, …}

func EncodeBool

func EncodeBool(x bool) uint64

EncodeBool encodes a bool as a uint64.

Input:  {false, true}
Output: {    0,    1}

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL