OPs implementation requires 2 comparisons. I think this C expression is clearer, and will sometimes use 1 comparison: num max ? max : num
int clamp (int value, int min, int max)
And that one liner inside. And now you have a double evaluation bomb waiting to go out on your codebase.