Clamps a value within the given range. If the target value is invalid (not finite), returns the lower bound.
Provides two usage patterns for maximum flexibility:
assert(Num.clamp(150, 0, 100) === 100);assert(Num.clamp(-50, 0, 100) === 0);const clampToPercentage = Num.clamp(0, 100);assert(clampToPercentage(75) === 75);assert(clampToPercentage(150) === 100); Copy
assert(Num.clamp(150, 0, 100) === 100);assert(Num.clamp(-50, 0, 100) === 0);const clampToPercentage = Num.clamp(0, 100);assert(clampToPercentage(75) === 75);assert(clampToPercentage(150) === 100);
Clamps a value within the given range. If the target value is invalid (not finite), returns the lower bound.
Provides two usage patterns for maximum flexibility: