aboutsummaryrefslogtreecommitdiffstats
path: root/common/size.go
diff options
context:
space:
mode:
Diffstat (limited to 'common/size.go')
-rw-r--r--common/size.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/common/size.go b/common/size.go
index bd0fc85c7..6381499a4 100644
--- a/common/size.go
+++ b/common/size.go
@@ -26,10 +26,10 @@ type StorageSize float64
// String implements the stringer interface.
func (s StorageSize) String() string {
- if s > 1000000 {
- return fmt.Sprintf("%.2f mB", s/1000000)
- } else if s > 1000 {
- return fmt.Sprintf("%.2f kB", s/1000)
+ if s > 1048576 {
+ return fmt.Sprintf("%.2f MiB", s/1048576)
+ } else if s > 1024 {
+ return fmt.Sprintf("%.2f KiB", s/1024)
} else {
return fmt.Sprintf("%.2f B", s)
}
@@ -38,10 +38,10 @@ func (s StorageSize) String() string {
// TerminalString implements log.TerminalStringer, formatting a string for console
// output during logging.
func (s StorageSize) TerminalString() string {
- if s > 1000000 {
- return fmt.Sprintf("%.2fmB", s/1000000)
- } else if s > 1000 {
- return fmt.Sprintf("%.2fkB", s/1000)
+ if s > 1048576 {
+ return fmt.Sprintf("%.2fMiB", s/1048576)
+ } else if s > 1024 {
+ return fmt.Sprintf("%.2fKiB", s/1024)
} else {
return fmt.Sprintf("%.2fB", s)
}