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

Function encodeEandM

pkg/util/encoding/decimal.go:153–169  ·  view source on GitHub ↗

encodeEandM encodes the exponent and mantissa, appending the encoding to a byte buffer. The mantissa m can be stored in the spare capacity of appendTo.

(appendTo []byte, negative bool, e int, m []byte)

Source from the content-addressed store, hash-verified

151//
152// The mantissa m can be stored in the spare capacity of appendTo.
153func encodeEandM(appendTo []byte, negative bool, e int, m []byte) []byte {
154 var buf []byte
155 if n := len(m) + maxVarintSize + 2; n <= cap(appendTo)-len(appendTo) {
156 buf = appendTo[len(appendTo) : len(appendTo)+n]
157 } else {
158 buf = make([]byte, n)
159 }
160 switch {
161 case e < 0:
162 return append(appendTo, encodeSmallNumber(negative, e, m, buf)...)
163 case e >= 0 && e <= 10:
164 return append(appendTo, encodeMediumNumber(negative, e, m, buf)...)
165 case e >= 11:
166 return append(appendTo, encodeLargeNumber(negative, e, m, buf)...)
167 }
168 panic("unreachable")
169}
170
171// encodeVarExpNumber encodes a Uvarint exponent and mantissa into a buffer;
172// only used for small (less than 0) and large (greater than 10) exponents.

Callers 1

encodeDecimalFunction · 0.85

Calls 3

encodeSmallNumberFunction · 0.85
encodeMediumNumberFunction · 0.85
encodeLargeNumberFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…