diff --git a/ac_encode.py b/ac_encode.py index 7592d17..57aacd2 100644 --- a/ac_encode.py +++ b/ac_encode.py @@ -82,8 +82,10 @@ def encode(string, c0=BETA0, c1=BETA1, adaptive=True): # if the gap a-b is getting small, rescale it while a > QUARTER and b < THREEQU: charstack[0] += 1 - a += a - HALF - b += b - HALF + a *= 2 + b *= 2 + a -= HALF + b -= HALF assert a <= HALF assert b >= HALF