RAD Studio
ContentsIndex
PreviousUpNext
hypot, hypotl

Header File 

math.h  

Category 

Math Routines 

Prototype 

double hypot(double x, double y); 

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

Description 

Calculates hypotenuse of a right triangle. 

hypot calculates the value z where 

z2 = x2 + y2 and z >= 0 

This is equivalent to the length of the hypotenuse of a right triangle, if the lengths of the two sides are x and y. 

hypotl is the long double version; it takes long double arguments and returns a long double result. 

Return Value 

On success, these functions return z, a double (hypot) or a long double) (hypotl). On error (such as an overflow), they set the global variable errno to

ERANGE 
Result out of range 

and return the value HUGE_VAL (hypot) or _LHUGE_VAL) (hypotl). Error handling for these routines can be modified through the functions _matherr and _matherrl. 

Example  

#include <stdio.h>
#include <math.h>
int main(void)
{
 double result;
 double x = 3.0;
    double y = 4.0;
    result = hypot(x, y);
    printf("The hypotenuse is: %lf\n", result);
    return 0;
}

Portability

 
POSIX 
Win32 
ANSI C 
ANSI C++ 
hypot 
 
hypotl 
 
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!