MCPcopy Create free account
hub / github.com/egonelbre/exp / ZEncode

Function ZEncode

bit/zigzag.go:6–8  ·  view source on GitHub ↗

ZEncode implements zig-zag encoding The sign will be encoded as the least significant bit in the result ZEncode(x) < abs(x)*2

(x int64)

Source from the content-addressed store, hash-verified

4// The sign will be encoded as the least significant bit in the result
5// ZEncode(x) < abs(x)*2
6func ZEncode(x int64) uint64 {
7 return uint64((x << 1) ^ (x >> 63))
8}
9
10// ZDecode is the inverse operation of ZEncode
11// ZDecode(ZEncode(x)) == x

Callers 10

mainFunction · 0.92
maxbitsFunction · 0.92
EncodeMethod · 0.92
LessMethod · 0.92
LessMethod · 0.92
mainFunction · 0.92
EncodeMethod · 0.92
LessMethod · 0.92
LessMethod · 0.92
TestZigRandomFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestZigRandomFunction · 0.68