diff --git a/app/src/main/java/eu/depau/ddroid/utils/NumberToSizeString.kt b/app/src/main/java/eu/depau/ddroid/utils/NumberToSizeString.kt index d7ab803..b1c133d 100644 --- a/app/src/main/java/eu/depau/ddroid/utils/NumberToSizeString.kt +++ b/app/src/main/java/eu/depau/ddroid/utils/NumberToSizeString.kt @@ -2,7 +2,7 @@ package eu.depau.ddroid.utils // https://stackoverflow.com/a/3758880/1124621 -private fun humanReadableByteCount(bytes: T, si: Boolean = false): String where T : Comparable, T : Number { +private fun humanReadableByteCount(bytes: T, si: Boolean = true): String where T : Comparable, T : Number { val unit: Long = if (si) 1000 else 1024 if (bytes.toLong() < unit) return String.format("%.2f B", bytes) val exp = (Math.log(bytes.toDouble()) / Math.log(unit.toDouble())).toInt() @@ -10,9 +10,9 @@ private fun humanReadableByteCount(bytes: T, si: Boolean = false): String wh return String.format("%.2f %sB", bytes.toDouble() / Math.pow(unit.toDouble(), exp.toDouble()), pre) } -fun Long.toHRSize(si: Boolean = false) = humanReadableByteCount(this, si) -fun Float.toHRSize(si: Boolean = false) = humanReadableByteCount(this, si) -fun Double.toHRSize(si: Boolean = false) = humanReadableByteCount(this, si) -fun Int.toHRSize(si: Boolean = false) = humanReadableByteCount(this, si) -fun Byte.toHRSize(si: Boolean = false) = humanReadableByteCount(this, si) -fun Short.toHRSize(si: Boolean = false) = humanReadableByteCount(this, si) \ No newline at end of file +fun Long.toHRSize(si: Boolean = true) = humanReadableByteCount(this, si) +fun Float.toHRSize(si: Boolean = true) = humanReadableByteCount(this, si) +fun Double.toHRSize(si: Boolean = true) = humanReadableByteCount(this, si) +fun Int.toHRSize(si: Boolean = true) = humanReadableByteCount(this, si) +fun Byte.toHRSize(si: Boolean = true) = humanReadableByteCount(this, si) +fun Short.toHRSize(si: Boolean = true) = humanReadableByteCount(this, si) \ No newline at end of file