名稱空間
變體
操作

crealf, creal, creall

來自 cppreference.com
< c‎ | 數值‎ | 複數
定義在標頭檔案 <complex.h>
float       crealf( float complex z );
(1) (C99 起)
double      creal( double complex z );
(2) (C99 起)
long double creall( long double complex z );
(3) (C99 起)
定義於標頭檔案 <tgmath.h>
#define creal( z )
(4) (C99 起)
1-3) 返回 z 的實部。
4) 型別泛型宏:若 z 的型別為 long double complexlong double imaginarylong double,則呼叫 creall。若 z 的型別為 float complexfloat imaginaryfloat,則呼叫 crealf。若 z 的型別為 double complexdouble imaginarydouble 或任何整數型別,則呼叫 creal

目錄

[編輯] 引數

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.6 The creal functions (p: 198-199)
  • 7.25 型別通用數學 <tgmath.h> (p: 373-375)
  • G.7 型別通用數學 <tgmath.h> (p: 545)
  • C99 標準 (ISO/IEC 9899:1999)
  • 7.3.9.5 The creal functions (p: 180)
  • 7.22 型別通用數學 <tgmath.h> (p: 335-337)
  • G.7 型別通用數學 <tgmath.h> (p: 480)

[編輯] 參閱

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