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

Method Decode

coder/arith/encoding.go:60–79  ·  view source on GitHub ↗
(prob P)

Source from the content-addressed store, hash-verified

58}
59
60func (dec *Decoder) Decode(prob P) (bit uint) {
61 x := prob.midpoint32(dec.lo, dec.hi)
62
63 if dec.code <= x {
64 dec.hi = x
65 bit = 1
66 } else {
67 dec.lo = x + 1
68 bit = 0
69 }
70
71 for dec.lo^dec.hi < 1<<24 {
72 dec.code = dec.code<<8 | uint32(dec.data[dec.read])
73 dec.read++
74 dec.lo <<= 8
75 dec.hi = dec.hi<<8 | 0xff
76 }
77
78 return bit
79}

Callers 3

mainFunction · 0.95
mainFunction · 0.95
TestRandomEncodeDecodeFunction · 0.95

Calls 1

midpoint32Method · 0.80

Tested by 1

TestRandomEncodeDecodeFunction · 0.76