From c4acdf1b253b061dc65d6b745a386cc74506c557 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 18 Jul 2017 20:20:42 -0400 Subject: [PATCH] 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. --- tools/helpers/src/main/kotlin/DependencyDownloader.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/helpers/src/main/kotlin/DependencyDownloader.kt b/tools/helpers/src/main/kotlin/DependencyDownloader.kt index e280ad2cedd..0a30d32733c 100644 --- a/tools/helpers/src/main/kotlin/DependencyDownloader.kt +++ b/tools/helpers/src/main/kotlin/DependencyDownloader.kt @@ -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) {