≫ ホーム ≫ C言語ヘッダファイル別一覧 | C言語アルファベット別一覧 ≫ complex.h ≫ creal, crealf, creall
複素数の実部 (real part) を返します.
#include <complex.h>
double creal( double complex z );
creal 関数は,double complex 型の複素数 z の実部を double 型で返します.
#include <complex.h>
float crealf( float complex z );
crealf 関数は,float complex 型の複素数 z の実部を float 型で返します.
#include <complex.h>
long double creall( long double complex z );
creall 関数は,long double complex 型の複素数 z の実部を long double 型で返します.
以下に creal 関数を使用して複素数の実部を取得するサンプルプログラムを示します.
/* header files */
#include <stdio.h>
#include <stdlib.h>
#include <complex.h>
/* main */
int main(void) {
double complex z = 3.0 + 2.0 * I;
double re;
/* 実部を取得 */
re = creal(z);
printf("実部: %.1f\n", re);
return EXIT_SUCCESS;
}
サンプルプログラムの実行結果は以下のようになります.
実部: 3.0