_cabs
計算複數的絕對值。
double _cabs(
struct _complex z
);
參數
- z
複數
傳回值
如果成功,_cabs 傳回它的引數的絕對值。 於溢位時, _cabs 傳回 HUGE_VAL 和 errno 設為 ERANGE。 您可以修改 _matherr以變更錯誤處理。
備註
_cabs 函式會計算複數的絕對值,型別必須為 _complex結構。 z 結構是由實數元件 x 和虛數元件 y組成。 對 _cabs 的呼叫會產生等於該運算式 sqrtz.x*z.x + z.y(z.y 的值。
需求
常式 |
必要的標頭 |
---|---|
_cabs |
<math.h> |
如需更多關於相容性的資訊,請參閱入門介紹中的 相容性 (Compatibility) 。
範例
// 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。如需詳細資訊,請參閱平台叫用範例。