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

Function encodeDecimal

pkg/util/encoding/decimal.go:49–74  ·  view source on GitHub ↗
(appendTo []byte, d *apd.Decimal, invert bool)

Source from the content-addressed store, hash-verified

47}
48
49func encodeDecimal(appendTo []byte, d *apd.Decimal, invert bool) []byte {
50 if d.IsZero() {
51 // Negative and positive zero are encoded identically. Only nonsorting
52 // decimal encoding can retain the sign.
53 return append(appendTo, decimalZero)
54 }
55 neg := d.Negative != invert
56 switch d.Form {
57 case apd.Finite:
58 // ignore
59 case apd.Infinite:
60 if neg {
61 return append(appendTo, decimalNegativeInfinity)
62 }
63 return append(appendTo, decimalInfinity)
64 case apd.NaN:
65 if invert {
66 return append(appendTo, decimalNaNDesc)
67 }
68 return append(appendTo, decimalNaN)
69 default:
70 panic(errors.Errorf("unknown form: %s", d.Form))
71 }
72 e, m := decimalEandM(d, appendTo[len(appendTo):])
73 return encodeEandM(appendTo, neg, e, m)
74}
75
76// decimalEandM computes and returns the exponent E and mantissa M for d.
77//

Callers 2

EncodeDecimalAscendingFunction · 0.85
EncodeDecimalDescendingFunction · 0.85

Calls 3

decimalEandMFunction · 0.85
encodeEandMFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…