encodeMediumNumber encodes the exponent and mantissa into a buffer, only used when the exponent is in [0, 10]. The encoding must fit in encInto. The mantissa m can overlap with encInto. Returns the length-adjusted buffer.
(negative bool, e int, m []byte, encInto []byte)
| 222 | // |
| 223 | // Returns the length-adjusted buffer. |
| 224 | func encodeMediumNumber(negative bool, e int, m []byte, encInto []byte) []byte { |
| 225 | l := 1 + len(m) |
| 226 | if len(encInto) < l+1 { |
| 227 | panic("buffer too short") |
| 228 | } |
| 229 | // Because m can overlap with encInto, we must first copy m to the right place |
| 230 | // before modifying encInto. |
| 231 | copy(encInto[1:], m) |
| 232 | if negative { |
| 233 | encInto[0] = decimalNegMedium - byte(e) |
| 234 | onesComplement(encInto[1:l]) |
| 235 | } else { |
| 236 | encInto[0] = decimalPosMedium + byte(e) |
| 237 | } |
| 238 | encInto[l] = decimalTerminator |
| 239 | return encInto[:l+1] |
| 240 | } |
| 241 | |
| 242 | // DecodeDecimalAscending returns the remaining byte slice after decoding and the decoded |
| 243 | // decimal from buf. |
no test coverage detected
searching dependent graphs…