function clamp( v, min, max ) {
	if (
		isnan( v ) ||
		isnan( min ) ||
		isnan( max )
	) {
		return NaN;
	}
	// Simple cases...
	if ( v < min ) {
		return min;
	}
	if ( v > max ) {
		return max;
	}
	// Special cases for handling +-0.0...
	if ( min === 0.0 && isNegativeZero( v ) ) {
		return min; // +-0.0
	}
	if ( v === 0.0 && isNegativeZero( max ) ) {
		return max; // -0.0
	}
	// Case: min <= v <= max
	return v;
}
Restricts a double-precision floating-point number to a specified range.

@param {number} v - input value
@param {number} min - minimum value
@param {number} max - maximum value
@returns {number} value restricted to a specified range

@example
var v = clamp( 3.14, 0.0, 5.0 );
// returns 3.14

v = clamp( -3.14, 0.0, 5.0 );
// returns 0.0

v = clamp( 10.0, 0.0, 5.0 );
// returns 5.0

v = clamp( -0.0, 0.0, 5.0 );
// returns 0.0

v = clamp( 0.0, -0.0, 5.0 );
// returns 0.0

v = clamp( NaN, 0.0, 5.0 );
// returns NaN

v = clamp( 0.0, NaN, 5.0 );
// returns NaN

v = clamp( 3.14, 0.0, NaN );
// returns NaN