diff --git a/core/src/main/java/live/shirabox/core/util/Extensions.kt b/core/src/main/java/live/shirabox/core/util/Extensions.kt index 18e6daf..2a49071 100644 --- a/core/src/main/java/live/shirabox/core/util/Extensions.kt +++ b/core/src/main/java/live/shirabox/core/util/Extensions.kt @@ -1,5 +1,7 @@ package live.shirabox.core.util +import java.math.BigDecimal +import java.math.RoundingMode import java.security.MessageDigest @OptIn(ExperimentalStdlibApi::class) @@ -8,4 +10,6 @@ fun String.md5(): String { val digest = md.digest(this.toByteArray()) return digest.toHexString() } -fun Double.round(decimals: Int = 2): Double = "%.${decimals}f".format(this).toDouble() \ No newline at end of file +fun Double.round(decimals: Int = 2): Double { + return BigDecimal(this).setScale(decimals, RoundingMode.HALF_UP).toDouble() +} \ No newline at end of file