Question : how to round Double to 2 digit decimals
Answered by : evil-eel-gmvw0c4gxozy
import java.math.BigDecimal
import java.math.RoundingMode
val decimal = BigDecimal(3.14159265359).setScale(2, RoundingMode.HALF_EVEN)
println(decimal) // 3.14
Source : https://discuss.kotlinlang.org/t/how-do-you-round-a-number-to-n-decimal-places/8843/3 | Last Update : Wed, 20 Oct 21