Mendess
07/16/2022, 8:37 PMJeremy Griffes
07/16/2022, 9:25 PMimport kotlin.math.pow
fun Double.toString(decimalPlaces: Int) = 10.0.pow(decimalPlaces).toInt().let { exp ->
"${toInt()}.${(this * exp).toInt() % exp}"
}
3.1415926.toString(decimalPlaces = 2)
// Shows 3.14