MCPcopy Index your code
hub / github.com/lxn/walk / formatFloatString

Function formatFloatString

util.go:186–228  ·  view source on GitHub ↗
(s string, prec int, grouped bool)

Source from the content-addressed store, hash-verified

184}
185
186func formatFloatString(s string, prec int, grouped bool) string {
187 switch s {
188 case "NaN", "-Inf", "+Inf":
189 return s
190 }
191
192 s = strings.Replace(s, ".", decimalSepS, 1)
193 if !grouped {
194 return s
195 }
196
197 b := new(bytes.Buffer)
198
199 var firstDigit int
200 if len(s) > 0 && s[0] == '-' {
201 firstDigit = 1
202 b.WriteByte('-')
203 s = s[1:]
204 }
205
206 intLen := len(s) - maxi(1, prec) - 1
207
208 n := intLen % 3
209 if n != 0 {
210 b.WriteString(s[:n])
211 }
212 for i := n; i < intLen; i += 3 {
213 if b.Len() > firstDigit {
214 b.WriteByte(groupSepB)
215 }
216 b.WriteString(s[i : i+3])
217 }
218
219 b.WriteString(s[intLen:])
220
221 s = b.String()
222
223 if prec == 0 {
224 s = s[:len(s)-2]
225 }
226
227 return s
228}
229
230func applyEnabledToDescendants(window Window, enabled bool) {
231 wb := window.AsWindowBase()

Callers 4

FormatFloatFunction · 0.85
FormatFloatGroupedFunction · 0.85
formatBigRatFunction · 0.85
formatBigRatGroupedFunction · 0.85

Calls 3

maxiFunction · 0.85
LenMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…