Created
April 3, 2021 11:51
-
-
Save dragneelfps/e30df070a96d0d14c3e1cb06fc05e9a0 to your computer and use it in GitHub Desktop.
rounding doubles in kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Double.round(places: Int) = BigDecimal(this).setScale(places, RoundingMode.HALF_EVEN).toDouble() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment