Clamp value to a range