fix rounding

This commit is contained in:
Milos Kozak 2022-05-30 11:52:32 +02:00
parent 69ad28eaa0
commit a314de0ffc

View file

@ -4,7 +4,7 @@ import java.math.BigDecimal
import kotlin.math.abs import kotlin.math.abs
import kotlin.math.ceil import kotlin.math.ceil
import kotlin.math.floor import kotlin.math.floor
import kotlin.math.roundToLong import kotlin.math.round
/** /**
* Created by mike on 20.06.2016. * Created by mike on 20.06.2016.
@ -14,7 +14,7 @@ object Round {
@JvmStatic @JvmStatic
fun roundTo(x: Double, step: Double): Double = fun roundTo(x: Double, step: Double): Double =
if (x == 0.0) 0.0 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 @JvmStatic
fun floorTo(x: Double, step: Double): Double = fun floorTo(x: Double, step: Double): Double =