Clamp

Clamps a number within the inclusive lower and upper bounds.

CategoryNumbers
AuthorPol Gubau
Since1.0.0
Last Updated2025-03-15
TypeSync
CompatibilityUniversal

Example

  • Input

    clamp(10, 5, 15)

    Output:

    10

Return

Returns the clamped number within the specified bounds.

Type: number

Props

NameTypeDefaultRequiredDescription
valuenumbernullYesThe number to clamp.
minimumnumbernullNoThe minimum bound to clamp the number.
maximumnumbernullYesThe maximum bound to clamp the number.

Notes

If only one bound is provided, it returns the minimum of the value and the bound.

Tags

  • number
  • clamp
  • bounds
  • math

Related