nextTowards

inline actual fun Double.nextTowards(to: Double): Double (source)

Platform and version requirements: Kotlin 1.2

Returns the Double value nearest to this value in direction from this value towards the value to.

Special cases:

  • x.nextTowards(y) is NaN if either x or y are NaN
  • x.nextTowards(x) == x
inline fun Float.nextTowards(to: Float): Float (source)

Platform and version requirements: Kotlin 1.2, JVM

Returns the Float value nearest to this value in direction from this value towards the value to.

Special cases:

  • x.nextTowards(y) is NaN if either x or y are NaN
  • x.nextTowards(x) == x