Earlier quoted context omitted.
It gets a bit confusing when the order of arguments is different depending on the library. For instance, with std it's std::clamp(val, min, max), but with Qt it's qBound(min, val, max) (for some reason I think the order of arguments in qBound is more logical).
The expression Math.min(Math.max(num, min), max) is symmetric in min and num , so it doesn’t matter whether you interchange min and num (or, for that matter, max and num , but that is harder to see from that way to define the ‘clamp’ function)
(Though I've just checked gcc's definition of std::clamp and it looks like
__glibcxx_assert(!(__hi
so order of arguments does matter there.)