Namespaces
Variants

crealf, creal, creall

From cppreference.net
ヘッダー <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 complex long double imaginary または long double の場合、 creall が呼び出される。 z の型が float complex float imaginary または float の場合、 crealf が呼び出される。 z の型が double complex double imaginary double または任意の整数型の場合、 creal が呼び出される。

目次

パラメータ

z - 複素引数

戻り値

z の実数部。

この関数は全ての可能な入力に対して完全に規定されており、 math_errhandling で説明されているいかなるエラーにも影響されません。

注記

任意の複素変数 z について、 z == 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 creal関数群 (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 creal関数群 (p: 180)
  • 7.22 総称数学 <tgmath.h> (p: 335-337)
  • G.7 総称数学 <tgmath.h> (p: 480)

関連項目

(C99) (C99) (C99)
複素数の虚部を計算する
(関数)