Clips a value to a range. If out of range will be restrained to maximum nearest value, or a default value. This template is used by Map templates, and not normally used directly, though it can be. See Template:Map.

  • 1 - number to test
  • 2 - minimum value. Default is 0
  • 3 - maximum value. Default is 100
  • 4 - default value to use if test fails or value is outside range. Optional
Returns - arg1 clipped to the range of min to max. Returns 'min' if arg1 is less than 'min' or not a number, or 'max' if arg1 is more than 'max'. If arg2 is set then returns arg2 if arg1 is not a number or outside 'min' and 'max'. If not a number and no default is supplied then returns 'min'.

Bad or empty values

{{Map/Clip|bob}} → 0
{{Map/Clip}} → 0

Values in and out of range

{{Map/Clip|55}} → 55
{{Map/Clip|0}} → 0
{{Map/Clip|100}} → 100
{{Map/Clip|-1}} → 0
{{Map/Clip|101}} → 100

Values clipped to other extents

{{Map/Clip|-1|-200|200}} → -1
{{Map/Clip|101|-200|200}} → 101

Values out of range using default values rather than clipping

{{Map/Clip|101|||50}} → 50
{{Map/Clip|201|-200|200|-200}} → -200