Is there a name for function $f(x)=\max(a, \min(x, b))$, where $a \leq b$?
What actually this function does: it keeps value in bounds of $[a, b]$.
Asked
Active
Viewed 223 times
2
æ-ra-code
- 123
2 Answers
2
Is is called “clamp” in the C++ standard library, and also in the OpenGL graphics library.
References:
Martin R
- 113,040
-
Thanks for answer! Looks like I choose wrong StackExchange site to ask question, heh? But this is how I saw this question (in terms of min/max) despite it originally comes from programming area. But also answer is from that area.... hmmm... – æ-ra-code Jan 18 '21 at 14:30
1
I don't think there is any official "name" for this function. It is just a fancy way to express a piecewise linear function. It is very likely that people write it in such a compact way for a purpose of programming.
When $a=1$ and $b=4$, the graph of the function:

-MAX_INTandMAX_INT. Probably, this does not have a name unless you name it yourself .. :). – VIVID Jan 18 '21 at 13:55opt(x,a,b)=..., and mostly use it to avoid IOOBE while accessing arrays, but for years I have doubts about name, and now have enough courage to ask question here :D – æ-ra-code Jan 18 '21 at 14:06