Kotlin Round Double to 2 Decimal Point

December 28, 2018
val value = 3.14159265358979323

// round to 2 decimal: 3.14
"%.2f".format(value).toDouble()

// or
Math.round(value * 100) / 100.0
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.