MCPcopy Index your code
hub / github.com/kopia/kopia / toDecimalUnitStringImp

Function toDecimalUnitStringImp

internal/units/units.go:35–45  ·  view source on GitHub ↗
(f, thousand float64, prefixes []string, suffix string)

Source from the content-addressed store, hash-verified

33}
34
35func toDecimalUnitStringImp(f, thousand float64, prefixes []string, suffix string) string {
36 for i := range prefixes {
37 if f < 0.9*thousand {
38 return fmt.Sprintf("%v %v%v", niceNumber(f), prefixes[i], suffix)
39 }
40
41 f /= thousand
42 }
43
44 return fmt.Sprintf("%v %v%v", niceNumber(f), prefixes[len(prefixes)-1], suffix)
45}
46
47// BytesStringBase10 formats the given value as bytes with the appropriate base-10 suffix (KB, MB, GB, ...)
48func BytesStringBase10[T realNumber](b T) string {

Callers 1

toDecimalUnitStringFunction · 0.85

Calls 1

niceNumberFunction · 0.85

Tested by

no test coverage detected