Skip to content

Commit 15ff378

Browse files
authored
common: fix size comparison in StorageSize (#33105)
1 parent 3954259 commit 15ff378

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

common/size.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ type StorageSize float64
2626

2727
// String implements the stringer interface.
2828
func (s StorageSize) String() string {
29-
if s > 1099511627776 {
29+
if s >= 1099511627776 {
3030
return fmt.Sprintf("%.2f TiB", s/1099511627776)
31-
} else if s > 1073741824 {
31+
} else if s >= 1073741824 {
3232
return fmt.Sprintf("%.2f GiB", s/1073741824)
33-
} else if s > 1048576 {
33+
} else if s >= 1048576 {
3434
return fmt.Sprintf("%.2f MiB", s/1048576)
35-
} else if s > 1024 {
35+
} else if s >= 1024 {
3636
return fmt.Sprintf("%.2f KiB", s/1024)
3737
} else {
3838
return fmt.Sprintf("%.2f B", s)
@@ -42,13 +42,13 @@ func (s StorageSize) String() string {
4242
// TerminalString implements log.TerminalStringer, formatting a string for console
4343
// output during logging.
4444
func (s StorageSize) TerminalString() string {
45-
if s > 1099511627776 {
45+
if s >= 1099511627776 {
4646
return fmt.Sprintf("%.2fTiB", s/1099511627776)
47-
} else if s > 1073741824 {
47+
} else if s >= 1073741824 {
4848
return fmt.Sprintf("%.2fGiB", s/1073741824)
49-
} else if s > 1048576 {
49+
} else if s >= 1048576 {
5050
return fmt.Sprintf("%.2fMiB", s/1048576)
51-
} else if s > 1024 {
51+
} else if s >= 1024 {
5252
return fmt.Sprintf("%.2fKiB", s/1024)
5353
} else {
5454
return fmt.Sprintf("%.2fB", s)

0 commit comments

Comments
 (0)