Computes the length of a hypotenuse in a right-angle triangle.
#include <math.h> double hypot(double x, double y); float hypotf(float x, float y); long double hypotl(long double x, long double y);
x
A value representing the length of one side that is not the hypotenuse.
y
A value representing the length of other side that is not the hypotenuse.
These functions compute the square root of the sum of the squares of x and y. These functions may be more accurate than the expression sqrt(pow(x) + pow(y)).
If these functions cannot compute a value they set errno to ERANGE. Use fpclassify() to check the validity of the result returned by these functions.
This facility may not be available on configurations of the EWL that run on platforms that do not have floating-point math capabilities.
#include <math.h> #include <stdio.h> int main(void) { double r = 3.0; double s = 4.0; printf("(%f^2 + %f^2)^(.5) = %f\n",r,s,hypot(r,s)); return 0; } Output: (3.000000^2 + 4.000000^2)^(.5) = 5.000000.