diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-09-23 17:19:44 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-09-23 17:19:44 +0200 |
commit | a8be86761f6302894346498df121a499be3f93ad (patch) | |
tree | cf8aaefa3c9f4200e43709485327a60d0d4e6fa6 /src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt | |
parent | 2eed7efac2dab7ec54043d188d814b17052cebdd (diff) | |
download | skyhanni-a8be86761f6302894346498df121a499be3f93ad.tar.gz skyhanni-a8be86761f6302894346498df121a499be3f93ad.tar.bz2 skyhanni-a8be86761f6302894346498df121a499be3f93ad.zip |
fix rounding
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt index 58441ecab..dc7c4828c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt @@ -83,12 +83,10 @@ object NumberUtil { */ fun Double.roundTo(precision: Int): Double { val scale = 10.0.pow(precision) - return kotlin.math.round(scale) / scale + return kotlin.math.round(this * scale) / scale } - fun Float.roundTo(precision: Int): Float { - return toDouble().roundTo(precision).toFloat() - } + fun Float.roundTo(precision: Int): Float = toDouble().roundTo(precision).toFloat() @Deprecated("Use roundTo instead", ReplaceWith("this.roundTo(precision)")) fun Double.roundToPrecision(precision: Int) = this.roundTo(precision) |