From a314de0ffc00c399c7bb2eedb3e236615e3e6227 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 30 May 2022 11:52:32 +0200 Subject: [PATCH] fix rounding --- core/src/main/java/info/nightscout/androidaps/utils/Round.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/utils/Round.kt b/core/src/main/java/info/nightscout/androidaps/utils/Round.kt index f1d47b8e06..4d9f542775 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/Round.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/Round.kt @@ -4,7 +4,7 @@ import java.math.BigDecimal import kotlin.math.abs import kotlin.math.ceil import kotlin.math.floor -import kotlin.math.roundToLong +import kotlin.math.round /** * Created by mike on 20.06.2016. @@ -14,7 +14,7 @@ object Round { @JvmStatic fun roundTo(x: Double, step: Double): Double = if (x == 0.0) 0.0 - else BigDecimal.valueOf((x / step).roundToLong()).multiply(BigDecimal.valueOf(step)).toDouble() + else BigDecimal.valueOf(round(x / step) * step).toDouble() @JvmStatic fun floorTo(x: Double, step: Double): Double =