-
Notifications
You must be signed in to change notification settings - Fork 344
Closed
Description
My issue is somewhat related to #49.
I am working with files right now and was checking theirs sizes:
As you can see, lf
is the only one which shows wrong number but with the same prefix (M
). I would like to see an option to switch between metric/SI and binary units.
After a quick search, I think the only thing should be changed to switch to binary prefix is all 1000
replace with 1024
(of course a new setting should be also implemented):
Lines 209 to 235 in cb7aa13
if size < 1000 { | |
return fmt.Sprintf("%dB", size) | |
} | |
suffix := []string{ | |
"K", // kilo | |
"M", // mega | |
"G", // giga | |
"T", // tera | |
"P", // peta | |
"E", // exa | |
"Z", // zeta | |
"Y", // yotta | |
} | |
curr := float64(size) / 1000 | |
for _, s := range suffix { | |
if curr < 10 { | |
return fmt.Sprintf("%.1f%s", curr-0.0499, s) | |
} else if curr < 1000 { | |
return fmt.Sprintf("%d%s", int(curr), s) | |
} | |
curr /= 1000 | |
} | |
return "" | |
} |
krackout and climbTheStairs
Metadata
Metadata
Assignees
Labels
No labels