MCPcopy Create free account
hub / github.com/codehamr/codehamr / humanInt

Function humanInt

internal/tui/format.go:71–88  ·  view source on GitHub ↗

humanInt formats a non-negative integer with commas so a context window like 262144 reads as "262,144" rather than a wall of digits.

(n int)

Source from the content-addressed store, hash-verified

69// humanInt formats a non-negative integer with commas so a context window
70// like 262144 reads as "262,144" rather than a wall of digits.
71func humanInt(n int) string {
72 s := strconv.Itoa(n)
73 if len(s) <= 3 {
74 return s
75 }
76 var b strings.Builder
77 b.Grow(len(s) + (len(s)-1)/3)
78 head := len(s) % 3
79 if head == 0 {
80 head = 3
81 }
82 b.WriteString(s[:head])
83 for i := head; i < len(s); i += 3 {
84 b.WriteByte(',')
85 b.WriteString(s[i : i+3])
86 }
87 return b.String()
88}

Callers 2

handleProbeMethod · 0.85
TestHumanIntFormatFunction · 0.85

Calls 1

StringMethod · 0.80

Tested by 1

TestHumanIntFormatFunction · 0.68