fun Double.roundToInt(): Int
Rounds this Double value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.
Special cases:
x.roundToInt() == Int.MAX_VALUE
when x > Int.MAX_VALUE
x.roundToInt() == Int.MIN_VALUE
when x < Int.MIN_VALUE
IllegalArgumentException
- when this value is NaN
fun Float.roundToInt(): Int
Rounds this Float value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.
Special cases:
x.roundToInt() == Int.MAX_VALUE
when x > Int.MAX_VALUE
x.roundToInt() == Int.MIN_VALUE
when x < Int.MIN_VALUE
IllegalArgumentException
- when this value is NaN
© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.math/round-to-int.html