## clamp(var x,var a,var b);

Returns **x** clipped to the range **a..b**.

### Parameters:

**x** |
var to limit between a and b |

**a** |
lower limit |

**b** |
upper limit |

### Returns:

**a** |
if **x** is less than **a** |

**b** |
if **x** is greater than **b** |

**x** |
if **x** is between **a** and **b** |

### Remarks:

This is the same as, but faster than **maxv(a,minv(x,b))**.
### Speed:

Fast
### Algorithm:

x = maxv(a,minv(x,b))

### Example:

x = clamp(x,1,10); *// x can't be smaller than 1 and greater than 10*

### See also:

minv, maxv,
cycle
► latest
version online