?
This document uses PHP Chinese website manual Release
在頭文件<complex.h>中定義 | ||
---|---|---|
#define _Complex_I / *未指定* / | (自C99以來(lái)) |
_Complex_I宏擴(kuò)展為類型為const float _Complex的虛數(shù)單元的值。
當(dāng) I 不可用時(shí),可能會(huì)使用此宏,例如應(yīng)用程序未定義它時(shí)。
不像_Imaginary_I
和CMPLX
,使用該宏來(lái)構(gòu)造復(fù)數(shù)可能虛分量上失去零的符號(hào)。
#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標(biāo)準(zhǔn)(ISO / IEC 9899:2011):
7.3.1 / 4 _Complex_I(p:188)
C99標(biāo)準(zhǔn)(ISO / IEC 9899:1999):
7.3.1 / 2 _Complex_I(p:170)
_Imaginary_I(C99) | 虛數(shù)單位常數(shù)i(宏常數(shù)) |
---|---|
I(C99) | 復(fù)數(shù)或虛數(shù)單位常數(shù)i(宏常數(shù)) |