Created
October 21, 2020 09:49
-
-
Save nadar71/40ee082a4c44ac5a965d8fbeb8ae5393 to your computer and use it in GitHub Desktop.
Round double extensions
This file contains hidden or 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(decimals: Int): Double { | |
var multiplier = 1.0 | |
repeat(decimals) { multiplier *= 10 } | |
return round(this * multiplier) / multiplier | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment