This topic has not yet been rated - Rate this topic

# hypot, hypotf, hypotl, _hypot, _hypotf, _hypotl

Visual Studio 2013

Calculates the hypotenuse.

```double hypot(
double x,
double y
);
float hypotf(
float x,
float y
);
long double hypotl(
long double x,
long double y
);
double _hypot(
double x,
double y
);
float _hypotf(
float x,
float y
);
long double _hypotl(
long double x,
long double y
);
```
x, y

Floating-point values.

If successful, hypot returns the length of the hypotenuse; on overflow, hypot returns INF (infinity) and the errno variable is set to ERANGE. You can use _matherr to modify error handling.

The hypot functions calculate the length of the hypotenuse of a right triangle, given the length of the two sides x and y (in other words, the square root of x2 + y2).

The versions of the functions that have leading underscores are provided for compatibility with earlier standards. Their behavior is identical to the versions that don't have leading underscores. We recommend using the versions without leading underscores for new code.

Routine

hypot , hypotf, hypotl, _hypot, _hypotf, _hypotl

<math.h>

For more compatibility information, see Compatibility.

```// crt_hypot.c
// This program prints the hypotenuse of a right triangle.

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

int main( void )
{
double x = 3.0, y = 4.0;

printf( "If a right triangle has sides %2.1f and %2.1f, "
"its hypotenuse is %2.1f\n", x, y, _hypot( x, y ) );
}
```
`If a right triangle has sides 3.0 and 4.0, its hypotenuse is 5.0`

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.