Skip to content

Commit 1109e5b

Browse files
committed
Changed binary prefix function
Signed-off-by: Vishal Rana <[email protected]>
1 parent b79e295 commit 1109e5b

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

bytes/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fmt.Println(bytes.Format(1323))
1919
### Binary prefix
2020

2121
```go
22-
fmt.Println(bytes.FormatBin(1323))
22+
fmt.Println(bytes.FormatB(1323))
2323
```
2424

2525
`1.29 KiB`

bytes/bytes.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import (
66
"math"
77
)
88

9-
// Format formats bytes to string. For example, 1000 would returns 1 KB
9+
// Format formats bytes to string with decimal prefix. For example, 1000 would returns
10+
// 1 KB
1011
func Format(b uint64) string {
1112
return format(float64(b), false)
1213
}
1314

14-
// FormatBin formats bytes to string as specified by ICE standard. For example,
15-
// 1024 would return 1 KiB.
16-
func FormatBin(b uint64) string {
15+
// FormatB formats bytes to string with binary prefix. For example, 1024 would
16+
// return 1 KiB.
17+
func FormatB(b uint64) string {
1718
return format(float64(b), true)
1819
}
1920

bytes/bytes_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ func TestFormat(t *testing.T) {
2222
}
2323
}
2424

25-
func TestFormatBin(t *testing.T) {
26-
f := FormatBin(1323)
25+
func TestFormatB(t *testing.T) {
26+
f := FormatB(1323)
2727
if f != "1.29 KiB" {
2828
t.Errorf("formatted bytes should be 1.29 KiB, found %s", f)
2929
}

0 commit comments

Comments
 (0)