You're right, mathematically (which, after all, is the whole purpose of the function), it all happens correctly, and there's no inconsistency. I guess I was referring more to the perceived inconsistency in terms of the expected result from a user perspective, where the result "should" have stayed on just one of the interval's boundaries in the case of such an invalid order, without any toggling (for this scrolling example, that boundary would be 0, but in other cases it might be the other one, aka 81).There is where I am lost. What exactly is inconsistent with the results of the clamp function? As far as I can tell, it is behaving exactly as described.
Clamp is just shorthand for: (x < low) ? low : ((x > high) ? high : x).
But then, indeed, it's difficult to know which of the boundaries should the function stay at when the order of arguments is invalid, since it also depends on the direction of incrementing / decrementing. In the end letting the simple math and the conditionals do their job is probably better.
Sorry for bothering you with this and for the lack of clarity here. Some things are better left as they are, can't expect a function to read minds or figure out the desired result, at least not without complicating it further. Thanks for sharing your clear view on this, much appreciated!

Statistics: Posted by Yincognito — Today, 1:07 pm