?
This document uses PHP Chinese website manual Release
在頭文件<complex.h>中定義 | ||
---|---|---|
#define _Imaginary_I / *未指定* / | (自C99以來) |
_Imaginary_I宏用虛數(shù)單元的值展開為const float _Imaginary類型的值。
與C中的任何純虛數(shù)支持一樣,只有在支持虛數(shù)時(shí)才定義該宏。
定義__STDC_IEC_559_COMPLEX__的編譯器不需要支持虛數(shù)。POSIX建議檢查宏_Imaginary_I是否被定義為標(biāo)識(shí)虛數(shù)支持。 | (自C99開始)(直到C11) |
---|---|
如果定義了__STDC_IEC_559_COMPLEX__,則支持虛數(shù)。 | (自C11以來) |
這個(gè)宏允許從其實(shí)部和虛部組裝一個(gè)復(fù)數(shù)的精確方法,例如, (雙復(fù)數(shù))((double)x + _Imaginary_I *(double)y)。 這種模式在C11中被標(biāo)準(zhǔn)化為宏CMPLX。 請注意,如果使用_Complex_I,則允許此表達(dá)式將虛擬位置中的負(fù)零轉(zhuǎn)換為正零。
#include <stdio.h>#include <complex.h> int main(void){ double complex z = 0.0 + -0.0 * _Imaginary_I; printf("z = %.1f%+.1fi\n", creal(z), cimag(z));}
輸出:
z = 0.0-0.0i
C11標(biāo)準(zhǔn)(ISO / IEC 9899:2011):
7.3.1 / 5 _Imaginary_I(p:188)
G.6 / 1 _Imaginary_I(p:537)
C99標(biāo)準(zhǔn)(ISO / IEC 9899:1999):
7.3.1 / 3 _Imaginary_I(p:170)
G.6 / 1 _Imaginary_I(p:472)
_Complex_I(C99) | 復(fù)數(shù)單位常數(shù)i(宏常數(shù)) |
---|---|
I (C99) | 復(fù)數(shù)或虛數(shù)單位常數(shù)i(宏常數(shù)) |