Skip to content

Instantly share code, notes, and snippets.

@uberto
Created April 7, 2020 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uberto/a68a00a2290a520f21dfc322bc74e16e to your computer and use it in GitHub Desktop.
Save uberto/a68a00a2290a520f21dfc322bc74e16e to your computer and use it in GitHub Desktop.
import java.lang.Math.round as jround
import kotlin.math.round
fun main() {
val r = round(4.5) + round(9.5)
println("kotlin round 4.5+9.5 $r")
val r2 = round(5.5) + round(9.5)
println("kotlin round 5.5+9.5 $r2")
val r3 = jround(4.5) + jround(9.5)
println("java round 4.5+9.5 $r3")
val r4 = jround(5.5) + jround(9.5)
println("java round 5.5+9.5 $r4")
val r5 = round(-4.5) + round(-9.5)
println("kotlin round 4.5+9.5 $r5")
val r6 = jround(-4.5) + jround(-9.5)
println("java round -4.5-9.5 $r6")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment