This commit is contained in:
tom5079
2020-09-02 20:15:26 +09:00
parent ead68b5201
commit 37be8ccf7f
12 changed files with 76 additions and 51 deletions

View File

@@ -53,15 +53,15 @@ fun String.wordCapitalize() : String {
return result.joinToString(" ")
}
fun byteToString(byte: Long, precision : Int = 1) : String {
private val suffix = listOf(
"B",
"kB",
"MB",
"GB",
"TB" //really?
)
val suffix = listOf(
"B",
"kB",
"MB",
"GB",
"TB" //really?
)
fun byteToString(byte: Long, precision : Int = 1) : String {
var size = byte.toDouble(); var suffixIndex = 0
while (size >= 1024) {
@@ -70,7 +70,6 @@ fun byteToString(byte: Long, precision : Int = 1) : String {
}
return "%.${precision}f ${suffix[suffixIndex]}".format(size)
}
/**