MCPcopy Create free account
hub / github.com/dolthub/doltgresql / encodeVarExpNumber

Function encodeVarExpNumber

postgres/parser/encoding/decimal.go:192–214  ·  view source on GitHub ↗

encodeVarExpNumber encodes a Uvarint exponent and mantissa into a buffer; only used for small (less than 0) and large (greater than 10) exponents. If required, the mantissa should already be in ones complement. The encoding must fit in encInto. The mantissa m can overlap with encInto. Returns the

(tag byte, expAscending bool, exp uint64, m []byte, encInto []byte)

Source from the content-addressed store, hash-verified

190//
191// Returns the length-adjusted buffer.
192func encodeVarExpNumber(tag byte, expAscending bool, exp uint64, m []byte, encInto []byte) []byte {
193 // Because m can overlap with encInto, we must first copy m to the right place
194 // before modifying encInto.
195 var n int
196 if expAscending {
197 n = EncLenUvarintAscending(exp)
198 } else {
199 n = EncLenUvarintDescending(exp)
200 }
201 l := 1 + n + len(m)
202 if len(encInto) < l+1 {
203 panic("buffer too short")
204 }
205 copy(encInto[1+n:], m)
206 encInto[0] = tag
207 if expAscending {
208 EncodeUvarintAscending(encInto[1:1], exp)
209 } else {
210 EncodeUvarintDescending(encInto[1:1], exp)
211 }
212 encInto[l] = decimalTerminator
213 return encInto[:l+1]
214}
215
216// encodeSmallNumber encodes the exponent and mantissa into a buffer; only used
217// when the exponent is negative. See encodeVarExpNumber.

Callers 2

encodeSmallNumberFunction · 0.85
encodeLargeNumberFunction · 0.85

Calls 4

EncLenUvarintAscendingFunction · 0.85
EncLenUvarintDescendingFunction · 0.85
EncodeUvarintAscendingFunction · 0.85
EncodeUvarintDescendingFunction · 0.85

Tested by

no test coverage detected