I want 2 decimals after the comma, also when it's zero. The result has to be a Double.
val price: Double = 32.0
val result = price.toRoundedUpDouble()
private fun Double.toRoundedUpDouble(fraction: Int = 2) =
BigDecimal(this.toString()).setScale(fraction, RoundingMode.HALF_UP).toDouble()
32.0 becomes 32.0 but should be 32.00
32.4983 becomes 32.5 but should be 32.50
32.40 becomes 32.4 but should be 32.40