MCPcopy
hub / github.com/expr-lang/expr / humanizeBytes

Function humanizeBytes

repl/repl.go:134–146  ·  view source on GitHub ↗
(b uint64)

Source from the content-addressed store, hash-verified

132}
133
134func humanizeBytes(b uint64) string {
135 const unit = 1024
136 if b < unit {
137 return fmt.Sprintf("%d B", b)
138 }
139 div, exp := uint64(unit), 0
140 for n := b / unit; n >= unit; n /= unit {
141 div *= unit
142 exp++
143 }
144 return fmt.Sprintf("%.2f %ciB",
145 float64(b)/float64(div), "KMGTPE"[exp])
146}

Callers 1

mainFunction · 0.85

Calls 1

SprintfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…