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

Function encodeDecimal

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

Source from the content-addressed store, hash-verified

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

Callers 2

EncodeDecimalAscendingFunction · 0.85
EncodeDecimalDescendingFunction · 0.85

Calls 2

decimalEandMFunction · 0.85
encodeEandMFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…