名前空間
変種
操作

_Complex_I

From cppreference.com
< c‎ | numeric‎ | complex
ヘッダー <complex.h> で定義
#define _Complex_I /* 未指定 */
(C99以降)

_Complex_I マクロは、虚数単位の値を持つ const float _Complex 型の値に展開されます。

目次

[編集] 注記

このマクロは、I が利用できない場合、例えばアプリケーションによって未定義されている場合に使用されることがあります。

_Imaginary_I および CMPLX とは異なり、このマクロを複素数の構築に使用すると、虚数部のゼロの符号が失われる可能性があります。

[編集]

#include <stdio.h>
#include <complex.h>
 
#undef I
#define J _Complex_I // can be used to redefine I
 
int main(void)
{
    // can be used to construct a complex number
    double complex z = 1.0 + 2.0 * _Complex_I;
    printf("1.0 + 2.0 * _Complex_I = %.1f%+.1fi\n", creal(z), cimag(z));
 
    // sign of zero may not be preserved
    double complex z2 = 0.0 + -0.0 * _Complex_I;
    printf("0.0 + -0.0 * _Complex_I = %.1f%+.1fi\n", creal(z2), cimag(z2));
}

実行結果の例

1.0 + 2.0 * _Complex_I = 1.0+2.0i
0.0 + -0.0 * _Complex_I = 0.0+0.0i

[編集] 参照

  • C23標準 (ISO/IEC 9899:2024)
  • 7.3.1/4 _Complex_I (p: TBD)
  • C17標準 (ISO/IEC 9899:2018)
  • 7.3.1/4 _Complex_I (p: 136)
  • C11標準 (ISO/IEC 9899:2011)
  • 7.3.1/4 _Complex_I (p: 188)
  • C99標準 (ISO/IEC 9899:1999)
  • 7.3.1/2 _Complex_I (p: 170)

[編集] 関連項目

虚数単位定数 i
(マクロ定数) [編集]
(C99)
複素数または虚数単位定数 i
(マクロ定数) [編集]
English 日本語 中文(简体) 中文(繁體)