CLAMP
Limits a value to a specified minimum and maximum value range. If the specified value is below the minimum value or above the maximum value, the minimum value or maximum value, respectively, is returned.
Syntax
=CLAMP(value, min, max)
Arguments
Argument | Type | Description |
---|---|---|
value | Number | The value to clamp |
min | Number | The minimum value |
max | Number | The maximum value |
Examples
=CLAMP(3.14159, 0, 10)
→3.14159
Restricts the value 3.14159 to the range 0 - 10
=CLAMP(-3.14159, 0, 10)
→0
Restricts the value -3.14159 to the range 0 - 10
=CLAMP(3.14159, 0, 1)
→1
Restricts the value 3.14159 to the range 0 - 1
=CLAMP(3, 1.5, 2.5)
→2.5
Restricts the value 3 to the range 1.5 - 2.5
=CLAMP(1, 1.5, 2.5)
→1.5
Restricts the value 1 to the range 1.5 - 2.5
=CLAMP(2, 1.5, 2.5)
→2
Restricts the value 2 to the range 1.5 - 2.5
Updated 7 months ago