hypot, hypotf, hypotl, _hypot, _hypotf, _hypotl

빗변을 계산합니다.

구문

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
);
#define hypotf(X, Y) // Requires C11 or higher

매개 변수

x, y
부동 소수점 값입니다.

반환 값

성공하면 hypot는 빗변의 길이를 반환합니다. 오버플로 시 hypot는 INF(무한대)를 반환하고 errno 변수는 ERANGE로 설정됩니다. _matherr를 사용하여 오류 처리를 수정할 수 있습니다.

반환 코드에 대한 자세한 내용은 , , 및 를 참조하세요errno._sys_nerr_sys_errlist_doserrno

설명

hypot 함수는 두 변 xy의 길이가 제공된 경우(즉, x2 + y2의 제곱근) 정삼각형의 빗변 길이를 계산합니다.

이전 표준과의 호환성을 위해 선행 밑줄이 있는 함수 버전이 제공됩니다. 해당 동작은 선행 밑줄이 없는 버전과 동일합니다. 새 코드에는 선행 밑줄이 없는 버전을 사용하는 것이 좋습니다.

tgmath.h>hypot() 매크로를 <사용하는 경우 인수 형식에 따라 선택한 함수 버전이 결정됩니다. 자세한 내용은 형식 제네릭 수학을 참조하세요.

기본적으로 이 함수의 전역 상태는 애플리케이션으로 범위가 지정됩니다. 이 동작을 변경하려면 CRT의 전역 상태를 참조하세요.

요구 사항

루틴에서 반환된 값 필수 헤더
hypot, hypotf, hypotl, _hypot, _hypotf, _hypotl <math.h>
hypot 매크로 <tgmath.h>

호환성에 대한 자세한 내용은 호환성을 참조하세요.

예시

// 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

참고 항목

수학 및 부동 소수점 지원
_cabs
_matherr