function clamp(val, min, max) {
  return Math.min(Math.max(val, min), max);
}
The float result between the min and max values.

@param {number} val
@param {number} min
@param {number} max
@returns {number}