Clamp a number to a minimum and/or maximum value.

   8.clamp(nil, nil) #=> 8
   8.clamp(9, nil)   #=> 9
   8.clamp(nil, 6)   #=> 6
510165
def clamp(min, max)
      value = self
      value = [value, min].max if min
      value = [value, max].min if max
      value
    end
51648
function clamp (x, a, b) {
  return (x < a) ? a : ((x > b) ? b : x);
}
729830
def min=(m)
      m = m.to_i
      raise ArgumentError.new("Minimum value must be greater than 0 and less than or equal to maximum (#{max})") unless m > 0 && m <= max
      @min_threads = m
      m
    end
565147
def clamp(start, size, max_size)
      start += shift_vector(start)
      start -= shift_vector(max_size - (start + size))
      start
    end
6525
function(x, min, max) {
                    x = this._v(x, "r");
                    min = this._v(min, "r", 0);
                    max = this._v(max, "r", 1);
                    if(min > max) throw new Error("Minimum value cannot be greater than maximum value");

                    if(x < min || x > max) return 0;
                    if(min === max) return Infinity;


                    return 1/(max-min);
                }
1324576
private static double clamp(double d, double min, double max)
    {
        if (d < min)
        {
            return min;
        }
        if (d > max)
        {
            return max;
        }
        return d;
    }
1241208
function min(x) {
        var value;
        for (var i = 0; i < x.length; i++) {
            // On the first iteration of this loop, min is
            // undefined and is thus made the minimum element in the array
            if (x[i] < value || value === undefined) value = x[i];
        }
        return value;
    }
414426
function decodeAndClamp(value, addend, coefficient, max) {
    value = addend + value * coefficient;
    // Clamp the value to the range
    return (value < 0 ? 0 : (value > max ? max : value));
  }
1100702
def clamp_within_range(self, x, y):
        
        x = int(x)
        y = int(y)

        if x < 0:
            x = 0
        if y < 0:
            y = 0
        if x > self.size_in_tiles.X:
            x = self.size_in_tiles.X
        if y > self.size_in_tiles.Y:
            y = self.size_in_tiles.Y

        return x, y
668003
def limit=(limit)

      if !limit.nil? && limit > 200
        fail ArgumentError, "invalid value for 'limit', must be smaller than or equal to 200."
      end

      if !limit.nil? && limit < 1
        fail ArgumentError, "invalid value for 'limit', must be greater than or equal to 1."
      end

      @limit = limit
    end
64890
def set_limits(self, min_=None, max_=None):
        
        self._min, self._max = min_, max_
1044457
static double clamp(double x, double low, double high) {
        return x < low ? low : (x > high ? high : x);
    }
19040
function (uvs) {
            var clamp = true;

            for (var i = 0, len = uvs.length; i < len; i++) {
                if (uvs[i] < 0 || uvs[i] > 1) {
                    clamp = false;
                    break;
                }
            }

            return clamp;
        }
341228
function minValueNode(root) {
  var current = root;
  while (current.left) {
    current = current.left;
  }
  return current;
}
1254815
def _in_range_inclusive(cls, val, **kwargs):
        '''
        
        '''
        minimum = kwargs.get('min', 0)
        maximum = kwargs.get('max', 1)
        zero_value = kwargs.get('zero_value', 0)

        if isinstance(val, six.string_types):
            if val.lower() == 'not defined':
                return True
            else:
                try:
                    val = int(val)
                except ValueError:
                    return False
        if val is not None:
            if minimum <= val <= maximum or val == zero_value:
                return True
            else:
                return False
        else:
            return False
703451
function clip(val, min, max) {
	return(val<min?min:(val>max?max:val));
}
917294
function (value, min, max) {
        min = min | 0;
        let length = ((value || '') + '').length;
        if (length < min) {
            return false;
        }
        if (max && length > max) {
            return false;
        }
        return true;
    }