hypotl Function

Calculates the square root of a sum of squared double precision floating-point values.

Include

<math.h>

Prototype

long double hypot(long double x, long double y);

Arguments

x
first argument, or length of one side
y
second argument, or length of other side

Return Value

Returns the square root of a sum of the arguments squared, being the hypotenuse of a right-angled triangle with perpendicular sides of length x and y.

Remarks

A range error might occur.

Example

#include <math.h>
#include <stdio.h>

int main(void)
{
  long double x, y, h;

  x = 1.75;
  y = 2.05
  h = hypotl(x, y);
  printf("The hypotenuse of a right-angle triangle with other side lengths of %Lf and %Lf is %Lf\n", x, y, h);
}

Example Output

The hypotenuse of a right-angle triangle with other side lengths of 1.750000 and 2.050000 is 2.695366