← All exercises

Clamp

easy

Constrains a numeric value between 0 and 100.

What it teaches

Force a value to stay between 0 and 100. Anything above 100 gets pinned to 100; anything below 0 gets pinned to 0; inside the range, the value passes through unchanged. The everyday guardrail pattern for sensor readings and setpoints.

Inputs and outputs

TagTypeDefaultDescription
In_ValueREALInput value to be clamped
Out_ValueREALClamped output value

Required behavior