func encodeInt(to []byte, base, x int) []byte { switch { case base < 2: base = 2 case base > 255: base = 255 } var ( div = uint(base) cut = uint(256 - base) num = uint(x) << 1 ) if x < 0 { num = ^num } for num > cut { num -= cut put := cut + num%div to = append(to, byte(put)) num /= div } return append( to, byte(num), ) }
To receive a hint, submit unfixed code.