Skip to content

Instantly share code, notes, and snippets.

@nadar71
Created October 21, 2020 09:49
Show Gist options
  • Save nadar71/40ee082a4c44ac5a965d8fbeb8ae5393 to your computer and use it in GitHub Desktop.
Save nadar71/40ee082a4c44ac5a965d8fbeb8ae5393 to your computer and use it in GitHub Desktop.
Round double extensions
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