Share via


_cabs

計算複合的數字的絕對值。

double _cabs( 
   struct _complex z 
);

參數

  • z
    複合的數字。

傳回值

_cabs如果成功的話會傳回其引數的絕對值。 On overflow, _cabs returns HUGE_VAL and sets errno to ERANGE. 您可以變更錯誤處理常式 _matherr

備註

_cabs函數會計算絕對值的複數,必須是型別的結構 _complex。 結構z是由真正的元件所組成x和虛構的元件y。 A call to _cabs produces a value equivalent to that of the expression sqrt( z.x*z.x+z.y*z.y ).

需求

常式

所需的標頭

_cabs

<math.h>

如需相容性資訊,請參閱相容性在簡介中。

範例

// crt_cabs.c
/* Using _cabs, this program calculates
 * the absolute value of a complex number.
 */
#include <math.h>
#include <stdio.h>

int main( void )
{
   struct _complex number = { 3.0, 4.0 };
   double d;

   d = _cabs( number );
   printf( "The absolute value of %f + %fi is %f\n",
           number.x, number.y, d );
}
  

.NET Framework 對等用法

不適用。 若要呼叫標準的 c 函式,使用PInvoke。 如需詳細資訊,請參閱平台叫用範例

請參閱

參考

浮點支援

abs _abs64

fabs fabsf

labs