W3cubDocs

/Kotlin

nextTowards

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

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

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

© 2010–2018 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.math/next-towards.html