頭文件:#include math.h
我們提供的服務(wù)有:網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、漳縣ssl等。為上1000+企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的漳縣網(wǎng)站制作公司
定義函數(shù):double sin(double x);
函數(shù)說明:sin()用來計(jì)算參數(shù)x 的正玄值,然后將結(jié)果返回。
返回值:返回-1 至1 之間的計(jì)算結(jié)果。
范例#include math.h
main(){
double answer = sin(0.5);
printf("sin(0.5) = %f\n", answer);
}
執(zhí)行
sin(0.5) = 0.479426
C庫函數(shù)手冊---math.h、stdlib.h、string.h、float.h
數(shù)學(xué)函數(shù),所在函數(shù)庫為math.h、stdlib.h、string.h、float.h
int abs(int i) 返回整型參數(shù)i的絕對值
double cabs(struct complex znum) 返回復(fù)數(shù)znum的絕對值
double fabs(double x) 返回雙精度參數(shù)x的絕對值
long labs(long n) 返回長整型參數(shù)n的絕對值
double exp(double x) 返回指數(shù)函數(shù)ex的值
double frexp(double value,int *eptr) 返回value=x*2n中x的值,n存貯在eptr中
double ldexp(double value,int exp); 返回value*2exp的值
double log(double x) 返回logex的值
double log10(double x) 返回log10x的值
double pow(double x,double y) 返回xy的值
double pow10(int p) 返回10p的值
double sqrt(double x) 返回+√x的值
double acos(double x) 返回x的反余弦cos-1(x)值,x為弧度
double asin(double x) 返回x的反正弦sin-1(x)值,x為弧度
double atan(double x) 返回x的反正切tan-1(x)值,x為弧度
double atan2(double y,double x) 返回y/x的反正切tan-1(x)值,y的x為弧度
double cos(double x) 返回x的余弦cos(x)值,x為弧度
double sin(double x) 返回x的正弦sin(x)值,x為弧度
double tan(double x) 返回x的正切tan(x)值,x為弧度
double cosh(double x) 返回x的雙曲余弦cosh(x)值,x為弧度
double sinh(double x) 返回x的雙曲正弦sinh(x)值,x為弧度
double tanh(double x) 返回x的雙曲正切tanh(x)值,x為弧度
double hypot(double x,double y) 返回直角三角形斜邊的長度(z),
x和y為直角邊的長度,z2=x2+y2
double ceil(double x) 返回不小于x的最小整數(shù)
double floor(double x) 返回不大于x的最大整數(shù)
void srand(unsigned seed) 初始化隨機(jī)數(shù)發(fā)生器
int rand() 產(chǎn)生一個(gè)隨機(jī)數(shù)并返回這個(gè)數(shù)
double poly(double x,int n,double c[])從參數(shù)產(chǎn)生一個(gè)多項(xiàng)式
double modf(double value,double *iptr)將雙精度數(shù)value分解成尾數(shù)和階
double fmod(double x,double y) 返回x/y的余數(shù)
double frexp(double value,int *eptr) 將雙精度數(shù)value分成尾數(shù)和階
double atof(char *nptr) 將字符串nptr轉(zhuǎn)換成浮點(diǎn)數(shù)并返回這個(gè)浮點(diǎn)數(shù)
double atoi(char *nptr) 將字符串nptr轉(zhuǎn)換成整數(shù)并返回這個(gè)整數(shù)
double atol(char *nptr) 將字符串nptr轉(zhuǎn)換成長整數(shù)并返回這個(gè)整數(shù)
char *ecvt(double value,int ndigit,int *decpt,int *sign)
將浮點(diǎn)數(shù)value轉(zhuǎn)換成字符串并返回該字符串
char *fcvt(double value,int ndigit,int *decpt,int *sign)
將浮點(diǎn)數(shù)value轉(zhuǎn)換成字符串并返回該字符串
char *gcvt(double value,int ndigit,char *buf)
將數(shù)value轉(zhuǎn)換成字符串并存于buf中,并返回buf的指針
char *ultoa(unsigned long value,char *string,int radix)
將無符號整型數(shù)value轉(zhuǎn)換成字符串并返回該字符串,radix為轉(zhuǎn)換時(shí)所用基數(shù)
char *ltoa(long value,char *string,int radix)
將長整型數(shù)value轉(zhuǎn)換成字符串并返回該字符串,radix為轉(zhuǎn)換時(shí)所用基數(shù)
char *itoa(int value,char *string,int radix)
將整數(shù)value轉(zhuǎn)換成字符串存入string,radix為轉(zhuǎn)換時(shí)所用基數(shù)
double atof(char *nptr) 將字符串nptr轉(zhuǎn)換成雙精度數(shù),并返回這個(gè)數(shù),錯誤返回0
int atoi(char *nptr) 將字符串nptr轉(zhuǎn)換成整型數(shù), 并返回這個(gè)數(shù),錯誤返回0
long atol(char *nptr) 將字符串nptr轉(zhuǎn)換成長整型數(shù),并返回這個(gè)數(shù),錯誤返回0
double strtod(char *str,char **endptr)將字符串str轉(zhuǎn)換成雙精度數(shù),并返回這個(gè)數(shù),
long strtol(char *str,char **endptr,int base)將字符串str轉(zhuǎn)換成長整型數(shù),
并返回這個(gè)數(shù),
int matherr(struct exception *e)
用戶修改數(shù)學(xué)錯誤返回信息函數(shù)(沒有必要使用)
double _matherr(_mexcep why,char *fun,double *arg1p,
double *arg2p,double retval)
用戶修改數(shù)學(xué)錯誤返回信息函數(shù)(沒有必要使用)
unsigned int _clear87() 清除浮點(diǎn)狀態(tài)字并返回原來的浮點(diǎn)狀態(tài)
void _fpreset() 重新初使化浮點(diǎn)數(shù)學(xué)程序包
unsigned int _status87() 返回浮點(diǎn)狀態(tài)字
一些數(shù)學(xué)計(jì)算的公式的具體實(shí)現(xiàn)是放在math.h里,具體有:
double sin (double x); x的正弦值
double cos (double x); x的余弦值
double tan (double x); x的正切值
double asin (double x); 結(jié)果介于[-PI/2, PI/2],x值域?yàn)閇-1,1]
double acos (double x); 結(jié)果介于[0, PI],x值域?yàn)閇-1,1]
double atan (double x); 反正切(主值), 結(jié)果介于[-PI/2, PI/2]
double atan2 (double y, double x); 反正切(整圓值), 結(jié)果介于[-PI, PI]
double sinh (double x); x的雙曲正弦值
double cosh (double x); x的雙曲余弦值
double tanh (double x); x的雙曲正切值
double exp (double x); 冪函數(shù)e^x
double pow (double x, double y); x^y,如果x=0且y=0,或者x0且y不是整型數(shù),將產(chǎn)生定義域錯誤
double sqrt (double x); x的平方根,其中x=0
double log (double x); 以e為底的對數(shù),自然對數(shù),x0
double log10 (double x); 以10為底的對數(shù),x0
double ceil (double x); 取上整
double floor (double x); 取下整
double fabs (double x); x的絕對值
double frexp (double x, int *exp); 標(biāo)準(zhǔn)化浮點(diǎn)數(shù), x = f * 2^exp, 已知x求f, exp ( x介于[0.5, 1] )并返回f值
double ldexp (double x, int exp); 與frexp相反, 已知x, exp求x*2^exp
double modf (double x, double *ip); 將參數(shù)的整數(shù)部分通過指針回傳, 返回小數(shù)部分,整數(shù)部分保存在*ip中
double fmod (double x, double y); 返回兩參數(shù)相除x/y的余數(shù),符號與x相同。如果y為0,則結(jié)果與具體的額實(shí)現(xiàn)有關(guān)
名稱欄目:c語言math庫函數(shù)用法,c語言 math函數(shù)
分享地址:http://jinyejixie.com/article10/dsedodo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)、建站公司、營銷型網(wǎng)站建設(shè)、小程序開發(fā)、品牌網(wǎng)站建設(shè)、服務(wù)器托管
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)