How to to calculate the maximim or minimum of two numbers without using "if" ( or something equivalant to that manner)?
The above question is often asked in introductory computer science courses and is answered using this method.
Now although it is not obvious, but using absolute value is also equivalant to using an if statement e.g. defining Max(a,b) = a if a>b else b;
Besides using limits, is there another way of finding the maximum or minimum of two numbers?
sqrt(x*x)
is not a numerical overflow safe function – Naomi Apr 26 '20 at 08:22