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

Function encodeEandM

pkg/util/encoding/decimal.go:148–164  ·  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

146//
147// The mantissa m can be stored in the spare capacity of appendTo.
148func encodeEandM(appendTo []byte, negative bool, e int, m []byte) []byte {
149 var buf []byte
150 if n := len(m) + MaxVarintLen + 2; n <= cap(appendTo)-len(appendTo) {
151 buf = appendTo[len(appendTo) : len(appendTo)+n]
152 } else {
153 buf = make([]byte, n)
154 }
155 switch {
156 case e < 0:
157 return append(appendTo, encodeSmallNumber(negative, e, m, buf)...)
158 case e >= 0 && e <= 10:
159 return append(appendTo, encodeMediumNumber(negative, e, m, buf)...)
160 case e >= 11:
161 return append(appendTo, encodeLargeNumber(negative, e, m, buf)...)
162 }
163 panic("unreachable")
164}
165
166// encodeVarExpNumber encodes a Uvarint exponent and mantissa into a buffer;
167// 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…