Implement clamp with ternary for better optimization
Both clang and MSVC are very good at optimizing this ternary into minsd, maxsd compiler instructions. For gcc, this optimizes best if -ffast-math is used (since gcc might otherwise be pedantic about the handling of inf, nan, and negative zero).
Edited by David Gobbi