Fix humanReadable formatting of bytes.
Previously, Long.humanReadable would display byte unit suffixes as `kB`, `MB`, etc., even though the calculations on byte counts were using base 2 for calculations. I've revised this to display sizes in the format of `kiB` or `MiB`, for kebibyte, and mebibyte - the base 2 unit equivalents of kilobyte and megabyte respectively.
This commit is contained in:
@@ -135,7 +135,7 @@ class DependencyDownloader(dependenciesRoot: File,
|
|||||||
}
|
}
|
||||||
val exp = (Math.log(this.toDouble()) / Math.log(1024.0)).toInt()
|
val exp = (Math.log(this.toDouble()) / Math.log(1024.0)).toInt()
|
||||||
val prefix = "kMGTPE"[exp-1]
|
val prefix = "kMGTPE"[exp-1]
|
||||||
return "%.1f %sB".format(this / Math.pow(1024.0, exp.toDouble()), prefix)
|
return "%.1f %siB".format(this / Math.pow(1024.0, exp.toDouble()), prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateProgressMsg(url: String, currentBytes: Long, totalBytes: Long) {
|
private fun updateProgressMsg(url: String, currentBytes: Long, totalBytes: Long) {
|
||||||
|
|||||||
Reference in New Issue
Block a user