?
This document uses PHP Chinese website manual Release
在頭文件<math.h>中定義 | ||
---|---|---|
#define imaginary _Imaginary | (since C99) |
此宏擴(kuò)展到關(guān)鍵字_Imaginary。
這是一個(gè)方便的宏,使得它可以使用float imaginary
,double imaginary
以及long double imaginary
作為一種替代的方式來寫這三個(gè)純虛C型float _Imaginary
,double _Imaginary
和long double _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以來) |
程序被允許取消定義并可能重新定義imaginary
宏。
#include <stdio.h>#include <complex.h> int main(void){ double imaginary i = 2.0*I; // pure imaginary double f = 1.0; // pure real double complex z = f + i; // complex number printf("z = %.1f%+.1fi\n", creal(z), cimag(z));}
輸出:
z = 1.0+2.0i
C11標(biāo)準(zhǔn)(ISO / IEC 9899:2011):
7.3.1 / 5想象(p:188)
G.6 / 1假想(p:537)
C99標(biāo)準(zhǔn)(ISO / IEC 9899:1999):
7.3.1 / 3假想(p:170)
G.6 / 1想象(p:472)