Loading AI tools
来自维基百科,自由的百科全书
complex.h
是C標準函數庫中的標頭檔,提供了複數算術所需要的巨集定義與函數聲明。
C99及C++11都規定了關鍵字_Complex。因而有3種複數類型:
double _Complex
float _Complex
long double _Complex
次序不是必須遵守的,比如float _Complex也可以寫成_Complex float。
_Complex_I
擴充為類型為const float _Complex
的常數值,其值為虛數單位。
C99規定complex
作為巨集擴充為_Complex
。但C++未定義complex
巨集。
gcc僅支援complex type,不支援imaginary type。因此巨集I
擴充為_Complex_I
。
定義複數變數時,可以如此:
double _Complex v1=3.1+5*I;
double _Complex v2=3.2+5*_Complex_I;
float _Complex v3=4.6f+12.0IF; //必须先写i,后写f
_Complex float v4=8.2f+2.3if;
long double _Complex v5=1.23456789L+3.456789999iL; //必须先写i,后写L
也可以用CMPLX/CMPLXF/CMPLXL巨集來表示相應複數表達式。
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.