©
This document uses PHP Chinese website manual Release
在头文件<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.0i0.0 + -0.0 * _Complex_I = 0.0+0.0i
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)
_Imaginary_I(C99) | 虚数单位常数i(宏常数) |
---|---|
I(C99) | 复数或虚数单位常数i(宏常数) |