Skip to content

function clamp (shared-side)

Available since version: 0.3.0

Note

The return type will depend on x argument type.

This function returnes the x value in [min, max] range.

Declaration

integer|float clamp(integer|float x, integer|float min, integer|float max)

Parameters

  • integer|float x: the value that being tested if doesn't exceed min/max range, if it exceeds the boundaries, min/max argument values are returned instead.
  • integer|float min: the smallest possible value that x can achieve.
  • integer|float max: the largest possible value that x can achieve.

Returns integer|float

the clamped value.