Do you know about std::hypot(a, b)
and std::hypot(a, b, c)
? (The 3-argument
overload exists since C++17, sometimes referred to as hypot3.) Why do the C
and C++ standard libraries provide a function that is as simple as sqrt(a*a +
b*b)
? It doesn’t save enough characters to warrant its existence, right? Have
you ever considered what happens if the input values are “very” small or large?
Or if an input is an IEEE754 special value such as infinity or NaN? Have you
ever considered how precise the calculation is, especially if an exact answer
is obvious if one of the inputs is 0?