Added a clamp(val,min,max) function complete with type information.