MCPcopy
hub / github.com/nats-io/nats.go / commaFormat

Function commaFormat

bench/bench.go:304–320  ·  view source on GitHub ↗
(n int64)

Source from the content-addressed store, hash-verified

302}
303
304func commaFormat(n int64) string {
305 in := strconv.FormatInt(n, 10)
306 out := make([]byte, len(in)+(len(in)-2+int(in[0]/'0'))/3)
307 if in[0] == '-' {
308 in, out[0] = in[1:], '-'
309 }
310 for i, j, k := len(in)-1, len(out)-1, 0; ; i, j = i-1, j-1 {
311 out[j] = in[i]
312 if i == 0 {
313 return string(out)
314 }
315 if k++; k == 3 {
316 j, k = j-1, 0
317 out[j] = ','
318 }
319 }
320}
321
322// HumanBytes formats bytes as a human readable string
323func HumanBytes(bytes float64, si bool) string {

Callers 2

StringMethod · 0.85
StatisticsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected