We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4c1ddac commit bee9369Copy full SHA for bee9369
memory/size.go
@@ -131,17 +131,17 @@ func (size Size) Base10String() string {
131
132
switch {
133
case abs(size) >= EB*2/3:
134
- return fmt.Sprintf("%.1f EB", size.EB())
+ return fmt.Sprintf("%.2f EB", size.EB())
135
case abs(size) >= PB*2/3:
136
- return fmt.Sprintf("%.1f PB", size.PB())
+ return fmt.Sprintf("%.2f PB", size.PB())
137
case abs(size) >= TB*2/3:
138
- return fmt.Sprintf("%.1f TB", size.TB())
+ return fmt.Sprintf("%.2f TB", size.TB())
139
case abs(size) >= GB*2/3:
140
- return fmt.Sprintf("%.1f GB", size.GB())
+ return fmt.Sprintf("%.2f GB", size.GB())
141
case abs(size) >= MB*2/3:
142
- return fmt.Sprintf("%.1f MB", size.MB())
+ return fmt.Sprintf("%.2f MB", size.MB())
143
case abs(size) >= KB*2/3:
144
- return fmt.Sprintf("%.1f KB", size.KB())
+ return fmt.Sprintf("%.2f KB", size.KB())
145
}
146
147
return strconv.FormatInt(size.Int64(), 10) + " B"
memory/size_test.go
@@ -80,16 +80,16 @@ func TestBase10Size(t *testing.T) {
80
text string
81
}{
82
// basics
83
- {1 * pb, "1.0 PB"},
84
- {1 * eb, "1.0 EB"},
85
- {1 * tb, "1.0 TB"},
86
- {1 * gb, "1.0 GB"},
87
- {1 * mb, "1.0 MB"},
88
- {1 * kb, "1.0 KB"},
+ {1 * pb, "1.00 PB"},
+ {1 * eb, "1.00 EB"},
+ {1 * tb, "1.00 TB"},
+ {1 * gb, "1.00 GB"},
+ {1 * mb, "1.00 MB"},
+ {1 * kb, "1.00 KB"},
89
{1, "1 B"},
90
// complicated
91
- {68 * tb, "68.0 TB"},
92
- {256 * mb, "256.0 MB"},
+ {68 * tb, "68.00 TB"},
+ {256 * mb, "256.00 MB"},
93
{500, "500 B"},
94
{5, "5 B"},
95
0 commit comments