We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2219395 commit 892a10eCopy full SHA for 892a10e
bytes/bytes.go
@@ -25,13 +25,13 @@ func format(b float64, bin bool) string {
25
if b < unit {
26
return fmt.Sprintf("%.0f B", b)
27
} else {
28
- i := uint8(math.Floor(math.Log(b) / math.Log(unit)))
+ x := math.Floor(math.Log(b) / math.Log(unit))
29
pre := make([]byte, 1, 2)
30
- pre[0] = "KMGTPE"[i-1]
+ pre[0] = "KMGTPE"[uint8(x)-1]
31
if bin {
32
pre = pre[:2]
33
pre[1] = 'i'
34
}
35
- return fmt.Sprintf("%.02f %sB", b/math.Pow(unit, i), pre)
+ return fmt.Sprintf("%.02f %sB", b/math.Pow(unit, x), pre)
36
37
0 commit comments