Skip to content

Limit to interval — clamp (math_constrain)

What it does: Limits the value of X to the range [LOW, HIGH].

math_constrain

Inputs

  • VALUE: input value.
  • LOW, HIGH: limits.

Output

  • number

Tips

  • Verify that LOW ≤ HIGH (otherwise the generated code may throw boundaries).
  • The generated expression is min(max(VALUE, LOW), HIGH); at LOW > HIGH the result does not match the normal interval.