clamp

open fun clamp(value: Float, min: Float, max: Float): Float(source)
open fun clamp(value: Double, min: Double, max: Double): Double(source)
open fun clamp(value: Int, min: Int, max: Int): Int(source)
open fun clamp(value: Long, min: Long, max: Long): Long(source)

This method takes a numerical value and ensures it fits in a given numerical range. If the number is smaller than the minimum required by the range, then the minimum of the range will be returned. If the number is higher than the maximum allowed by the range then the maximum of the range will be returned.

Return

the clamped value.

Parameters

value

the value to be clamped.

min

minimum resulting value.

max

maximum resulting value.