clamp - Restricts a value to be within a specified range
int32 clamp(int32 num, int32 lo, int32 hi);
fix32 clamp(fix32 num, fix32 lo, fix32 hi);
Computes the value of num clamped to the range defined by lo and hi.
The clamped value of num.
init { printf("%d", clamp(55, 1, 10)); // 10 printf("%d", clamp(-15, 1, 10)); // 1 printf("%.1f", clamp(4.5, 1.0, 10.0)); // 4.5 }