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:
Daniel
2017-07-18 20:20:42 -04:00
committed by ilmat192
parent d6e0f67d4e
commit c4acdf1b25
@@ -135,7 +135,7 @@ class DependencyDownloader(dependenciesRoot: File,
}
val exp = (Math.log(this.toDouble()) / Math.log(1024.0)).toInt()
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) {