MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / encodeMediumNumber

Function encodeMediumNumber

pkg/util/encoding/decimal.go:229–245  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

227//
228// Returns the length-adjusted buffer.
229func 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.

Callers 1

encodeEandMFunction · 0.85

Calls 1

onesComplementFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…