W3cubDocs

/Kotlin

nextTowards

Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
fun Double.nextTowards(to: Double): Double

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
Platform and version requirements: JVM (1.2), Native (1.2)
fun Float.nextTowards(to: Float): Float

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–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/next-towards.html