_cabs

计算复数的绝对值。

double _cabs( 
   struct _complex z 
);

参数

  • z
    复数。

返回值

如果成功,_cabs 返回绝对值参数。 溢出,_cabs 返回 HUGE_VAL 并将 errno 设置为 ERANGE。 您可以更改与 _matherr中的错误处理。

备注

_cabs 函数计算复数的绝对值,必须为类型_complex结构。 结构 z 由实际组件 x 和假设组件的 y组成。 对 _cabs 的调用将产生表达式的等效值 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、llabs