_hypot, hypotf

计算此根个字符串。

double _hypot( 
   double x,
   double y 
);
float _hypotf( 
   float x,
   float y 
);

参数

  • x, y
    浮点值。

返回值

_hypot 返回根个字符串,如果成功或 INF (无穷大) 的长度在溢出。 errno 变量设置为在溢出的 ERANGE 。 可以修改错误处理与 _matherr。

有关此更改和其他的更多信息返回代码示例,请参见 _doserrno、 errno、 _sys_errlist 和 _sys_nerr

平台

_hypotf 只有在 Itanium 处理器家族 (IPF) (ipf) 平台。 _hypot 可在所有平台。

备注

_hypot 函数求值直角三角形的个字符串的长度为双方 x 和 y (换言之,即的长度 x2 + y2)。

要求

实例

必需的头

_hypot

math.h

hypotf

math.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 ) );
}
  

.NET Framework 等效项

不适用。若要调用标准 C 函数,请使用 PInvoke。有关更多信息,请参见 平台调用示例

请参见

参考

浮点支持

_cabs

_matherr