hypot() — 빗변 계산
형식
#include <math.h>
double hypot(double side1, double side2);
언어 레벨
ANSI
스레드세이프
예
설명
hypot() 함수는 side1 및
side2의 두 변의 길이를 기반으로 직각삼각형의 빗변의 길이를 계산합니다.
hypot()
함수에 대한 호출은 다음과 같습니다.
sqrt(side1 * side1 + side2 * side2);
리턴값
hypot() 함수는 직각삼각형의 빗변의 길이를 리턴합니다. 결과가 오버플로인 경우, hypot()는 errno을 ERANGE로 설정하고 값 HUGE_VAL을 리턴합니다. 결과가 언더플로인 경우, hypot()는 errno를 ERANGE로 설정하고 0(영)을 리턴합니다. errno의 값은 EDOM으로 설정될 수도 있습니다.
예
이 예는 변이 3.0과 4.0인 직각삼각형의 빗변을 계산합니다.
#include <math.h>
int main(void)
{
double x, y, z;
x = 3.0;
y = 4.0;
z = hypot(x,y);
printf("The hypotenuse of the triangle with sides %lf and %lf"
" is %lf\n", x, y, z);
}
/******************** Output should be similar to: **************
The hypotenuse of the triangle with sides 3.000000 and 4.000000 is 5.000000
*/