wrap

fun wrap(n: Double, min: Double, max: Double): Double
fun wrap(n: Int, min: Int, max: Int): Int

Ensures that n lies in the range min..max, where min and max are modularly-equivalent (that is, n wraps around).


@JvmName(name = "wrap1")
fun Double.wrap(min: Double, max: Double): Double
@JvmName(name = "wrap1")
fun Double.wrap(bounds: Pair<Double, Double>): Double
@JvmName(name = "wrap1")
fun Int.wrap(min: Int, max: Int): Int

See also