Protecting Coders From Ourselves: Min, Max, Lerp, and Clamp

Imagine this: you’ve got some value, x , that you want to ensure is at least 1 . That is to say, you want to ensure its minimum value is 1 . So, being the smart, experienced programmer that you are, you write the following: x = Min ( x , 1 ) ; You give yourself the small, satisfied nod of a job well done and run the program and then it all goes immediately sideways because that should have been…