While programming I came up with a the following equation / workflow

```
clampValue = (value - minValueofRange) / (maxValueofRange - minValueofRange);
clippedValue = min(1, max(0, clampValue));
finalValue = clippedValue * scale;

```

Now the clipping ultimately causes an `if` and `else` in programming. Can we convert it completely to a mathematical equation?

**Edit:**

max and min are functions in c++ defined like:

```
int max(int v1, int v2){
    if(v1 > v2) return v1;
    else return v2;
}

```

Similar for the min() function