clamp
Returns the receiver limited to an inclusive [min, max] range.
API Reference
Signature
Parameters
Returns
Returns a new Arith instance: min if the receiver is below range, max if above range, otherwise a copy of the receiver.
Throws
- Throws if
minis greater thanmax. - Throws if an input value is invalid while
STRICTistrue.
Agent Contract
Agent Notes
- Prefer
clamp()over manuallt/gtbranching when returning a boundedArithvalue. - Do not use JavaScript
Math.minorMath.maxonArithvalues. - Treat
Arithinstances as immutable.