名稱空間
變體
操作

cimagf, cimag, cimagl

來自 cppreference.com
< c‎ | 數值‎ | 複數
定義在標頭檔案 <complex.h>
float       cimagf( float complex z );
(1) (C99 起)
double      cimag( double complex z );
(2) (C99 起)
long double cimagl( long double complex z );
(3) (C99 起)
定義於標頭檔案 <tgmath.h>
#define cimag( z )
(4) (C99 起)
1-3) 返回 z 的虛部。
4) 型別通用宏:如果 z 的型別是 long double complexlong double imaginarylong double,則呼叫 cimagl。如果 z 的型別是 float complexfloat imaginaryfloat,則呼叫 cimagf。如果 z 的型別是 double complexdouble imaginarydouble 或任何整數型別,則呼叫 cimag

目錄

[編輯] 引數

z - 複數引數

[編輯] 返回值

z 的虛部。

此函式對所有可能的輸入都完全指定,不受 math_errhandling 中描述的任何錯誤的影響。

[編輯] 注意

對於任何復變數 zz == creal(z) + I*cimag(z)

[編輯] 示例

#include <stdio.h>
#include <complex.h>
 
int main(void)
{    
    double complex z = 1.0 + 2.0*I;
    printf("%f%+fi\n", creal(z), cimag(z));
}

輸出

1.000000+2.000000i

[編輯] 參考資料

  • C11 標準 (ISO/IEC 9899:2011)
  • 7.3.9.2 cimag 函式 (p: 197)
  • 7.25 型別通用數學 <tgmath.h> (p: 373-375)
  • G.7 型別通用數學 <tgmath.h> (p: 545)
  • C99 標準 (ISO/IEC 9899:1999)
  • 7.3.9.2 cimag 函式 (p: 178-179)
  • 7.22 型別通用數學 <tgmath.h> (p: 335-337)
  • G.7 型別通用數學 <tgmath.h> (p: 480)

[編輯] 另請參閱

(C99 起)(C99 起)(C99 起)
計算複數的實部
(函式) [編輯]
C++ 文件 用於 imag