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)
| 227 | // |
| 228 | // Returns the length-adjusted buffer. |
| 229 | func encodeMediumNumber(negative bool, e int, m []byte, encInto []byte) []byte { |
| 230 | l := 1 + len(m) |
| 231 | if len(encInto) < l+1 { |
| 232 | panic("buffer too short") |
| 233 | } |
| 234 | // Because m can overlap with encInto, we must first copy m to the right place |
| 235 | // before modifying encInto. |
| 236 | copy(encInto[1:], m) |
| 237 | if negative { |
| 238 | encInto[0] = decimalNegMedium - byte(e) |
| 239 | onesComplement(encInto[1:l]) |
| 240 | } else { |
| 241 | encInto[0] = decimalPosMedium + byte(e) |
| 242 | } |
| 243 | encInto[l] = decimalTerminator |
| 244 | return encInto[:l+1] |
| 245 | } |
| 246 | |
| 247 | // DecodeDecimalAscending returns the remaining byte slice after decoding and the decoded |
| 248 | // decimal from buf. |
no test coverage detected
searching dependent graphs…