Clamp function for primitive types

IME if you’re actually trying to use NaN for something constructive, you want it to be propagated by everything. That is, NaN.clamp(lo, hi) should return the NaN (and so should min(NaN, x) and max(NaN, x) – I’m surprised to hear that they don’t).

The behavior of NaN in the lo and hi arguments matters considerably less, because those are much less likely to be data.

(I do not know whether this corresponds to the behavior of the x86 instructions mentioned above.)