-
Notifications
You must be signed in to change notification settings - Fork 15
clamp
Chung Leong edited this page Jan 10, 2022
·
3 revisions
clamp - Restrict a number to a given range
float clamp( float $x, float $minValue, float $maxValue )
clamp() returns minValue if x is smaller than minValue or maxValue if x is greater than maxValue. Otherwise it returns x.
x - The number to process. It can be a scalar or an array.
minValue - The minimum value. It can be a scalar or an array.
maxValue - The maximum value. It can be a scalar or an array.
A number between minValue and maxValue or NAN. If x, minValue, or y is an array, then return value is also an array, the size of which match the largest of the three.
1.0 and above.