MCPcopy Create free account
hub / github.com/cockroachdb/apd / fmtF

Function fmtF

format.go:125–146  ·  view source on GitHub ↗

%f: ddddddd.ddddd

(buf []byte, d *Decimal, digits []byte)

Source from the content-addressed store, hash-verified

123
124// %f: ddddddd.ddddd
125func fmtF(buf []byte, d *Decimal, digits []byte) []byte {
126 if d.Exponent < 0 {
127 if left := -int(d.Exponent) - len(digits); left >= 0 {
128 buf = append(buf, "0."...)
129 for i := 0; i < left; i++ {
130 buf = append(buf, '0')
131 }
132 buf = append(buf, digits...)
133 } else if left < 0 {
134 offset := -left
135 buf = append(buf, digits[:offset]...)
136 buf = append(buf, '.')
137 buf = append(buf, digits[offset:]...)
138 }
139 } else if d.Exponent >= 0 {
140 buf = append(buf, digits...)
141 for i := int32(0); i < d.Exponent; i++ {
142 buf = append(buf, '0')
143 }
144 }
145 return buf
146}
147
148var _ fmt.Formatter = decimalZero // *Decimal must implement fmt.Formatter
149

Callers 1

AppendMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…