What to call a function

What is a good simple name for this function? I want it to be somewhat short but something that tells you what it does.

1
2
3
4
5
6
7
8
9
10
11
12
// keeps value within parameters
function K(value,minimum,maximum){
    if (value < minimum){
        return minimum;
    }
    else if (value > maximum){
        return maximum;
    }
    else{
        return value;
    }
}
clipped(value,minimum,maximum)

(Give or take the tense of the verb).
Last edited on
The standard library uses the name clamp for this.
std::clamp() (C++17): http://en.cppreference.com/w/cpp/algorithm/clamp
Topic archived. No new replies allowed.