Drop un-needed decimal “.0”

You can use removeSuffix:

fun main() {
    println(100.5.toString().removeSuffix(".0"))
    println(100.0.toString().removeSuffix(".0"))
}

Output:

100.5
100

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top