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

Method Encode

coder/arith/encoding.go:16–30  ·  view source on GitHub ↗
(bit uint, prob P)

Source from the content-addressed store, hash-verified

14}
15
16func (enc *Encoder) Encode(bit uint, prob P) {
17 x := prob.midpoint32(enc.lo, enc.hi)
18
19 if bit == 1 {
20 enc.hi = x
21 } else {
22 enc.lo = x + 1
23 }
24
25 for enc.lo^enc.hi < 1<<24 {
26 enc.data = append(enc.data, byte(enc.lo>>24))
27 enc.lo <<= 8
28 enc.hi = enc.hi<<8 | 0xFF
29 }
30}
31
32func (enc *Encoder) Close() {
33 for i := 0; i < 4; i++ {

Callers 2

TestRandomEncodeDecodeFunction · 0.95
TestPackingFunction · 0.95

Calls 1

midpoint32Method · 0.80

Tested by 2

TestRandomEncodeDecodeFunction · 0.76
TestPackingFunction · 0.76