1.高斯函數(shù),向下取整
floor(1.0/4)=0;
floor(4.0/4)=1;
floor(5.0/4)=1;
floor(8.0/4)=2;
floor()方法是向下取整,類似于數(shù)學(xué)中的高斯函數(shù) [].取得不大于浮點(diǎn)數(shù)的最大整數(shù),對(duì)于正數(shù)來說是舍棄浮點(diǎn)數(shù)部分,對(duì)于復(fù)數(shù)來說,舍棄浮點(diǎn)數(shù)部分后再減1.
2.ceil函數(shù),向上取整。
如:
ceil(1.0/4)=1;
ceil(4.0/4)=1;
ceil(5.0/4)=2;
ceil(8.0/4)=2;
ceil()方法是向上取整, 括號(hào)內(nèi)是double類型
這兩個(gè)函數(shù)都是math.h庫(kù)里面的,直接使用就行
3、 三角函數(shù)
double sin (double); 正弦
double cos (double);余弦
double tan (double);正切
4 、反三角函數(shù)
double asin (double); 結(jié)果介于[-PI/2, PI/2]
double acos (double); 結(jié)果介于[0, PI]
double atan (double); 反正切(主值), 結(jié)果介于[-PI/2, PI/2]
double atan2 (double, double); 反正切(整圓值), 結(jié)果介于[-PI, PI]
5 、雙曲三角函數(shù)
double sinh (double);
double cosh (double);
double tanh (double);
6 、指數(shù)與對(duì)數(shù)
double exp (double);求取自然數(shù)e的冪
double sqrt (double);開平方
double log (double); 以e為底的對(duì)數(shù)
double log10 (double);以10為底的對(duì)數(shù)
double pow(double x, double y);計(jì)算以x為底數(shù)的y次冪
float powf(float x, float y); 功能與pow一致,只是輸入與輸出皆為浮點(diǎn)數(shù)
7 、取整
double ceil (double); 取上整
double floor (double); 取下整
8、絕對(duì)值
double fabs (double);求絕對(duì)值
double cabs(struct complex znum) ;求復(fù)數(shù)的絕對(duì)值
9、標(biāo)準(zhǔn)化浮點(diǎn)數(shù)
double frexp (double f, int *p); 標(biāo)準(zhǔn)化浮點(diǎn)數(shù), f = x * 2^p, 已知f求x, p ( x介于[0.5, 1] )
double ldexp (double x, int p); 與frexp相反, 已知x, p求f
10、取整與取余
double modf (double, double*); 將參數(shù)的整數(shù)部分通過指針回傳, 返回小數(shù)部分
double fmod (double, double); 返回兩參數(shù)相除的余數(shù)
11 、其他
double hypot(double x, double y);已知直角三角形兩個(gè)直角邊長(zhǎng)度,求斜邊長(zhǎng)度
double ldexp(double x, int exponent);計(jì)算x*(2的exponent次冪)
double poly(double x, int degree, double coeffs [] );計(jì)算多項(xiàng)式
nt matherr(struct exception *e);數(shù)學(xué)錯(cuò)誤計(jì)算處理程序
附:C語(yǔ)言常見的函數(shù)
rand() ----隨機(jī)數(shù)
abs() / labs() ----整數(shù)絕對(duì)值
fabs() / fabsf() / fabsl() ----浮點(diǎn)數(shù)絕對(duì)值
floor() / floorf() / floorl() ----向下取整
ceil() / ceilf() / ceill() ----向上取整
round() / roundf() / roundl() ----四舍五入
sqrt() / sqrtf() / sqrtl() ----求平方根
fmax() / fmaxf() / fmaxl() ----求最大值
fmin() / fminf() / fminl() ----求最小值
hypot() / hypotf() / hypotl() ----求直角三角形斜邊的長(zhǎng)度
fmod() / fmodf() / fmodl() ----求兩數(shù)整除后的余數(shù)
modf() / modff() / modfl() ----浮點(diǎn)數(shù)分解為整數(shù)和小數(shù)
frexp() / frexpf() / frexpl() ----浮點(diǎn)數(shù)分解尾數(shù)和二為底的指數(shù)
sin() / sinf() / sinl() ----求正弦值
sinh() / sinhf() / sinhl() ----求雙曲正弦值
cos() / cosf() / cosl() ----求余弦值
cosh() / coshf() / coshl() ----求雙曲余弦值
tan() / tanf() / tanl() ----求正切值
tanh() / tanhf() / tanhl() ----求雙曲正切值
asin() / asinf() / asinl() ----求反正弦值
asinh() / asinhf() / asinhl() ----求反雙曲正弦值
acos() / acosf() / acosl() ----求反余弦值
acosh() / acoshf() / acoshl() ----求反雙曲余弦值
atan() / atanf() / atanl() ----求反正切值
atan2() / atan2f() / atan2l() ----求坐標(biāo)值的反正切值
atanh() / atanhf() / atanhl() ----求反雙曲正切值