_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) 平台上。_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