Clamp function for primitive types