cmath.h是c++的标准库头文件,c表示其来自c标准库。
未收录完整
目录\( ̄︶ ̄*\))
参数为long型:long int labs(long int x);
参数为double型:double fabs(double x);
幂运算
开平方
double sqrt(double x);
x的y次方
double pow(double x,double y);
取绝对值
参数为int型:int abs(int x);
参数为long型:long int labs(long int x);
//long int 即long,当今计算机中大多时候long和int无区别,而long long int(long long)在cmath中没有对应的取绝对值函数,需要自己定义。
参数为double型:double fabs(double x);
参数为struct _complex型(复数)
double _cabs(struct _complex z);//来源于百度百科
取整函数
向上取整:double ceil(double x);
ex:double res=ceil(4.3);
cout<<res<<endl;
输出结果:5
向下取整:double floor(double x);
ex:double res=floor(4.3);
cout<<res<<endl;
输出结果:4
三角函数
正弦函数
double sin(double x);
余弦函数
double cos(double x);
正切函数
double tan(double x);
反三角函数
反余弦函数
double acos(double x) ; //x为弧度,返回x的反余弦arccos(x)值
参数x必须在[-1,1]之间。
反正弦函数
double asin(double x) ; //x为弧度,返回x的反正弦arcsin(x)值
参数x必须在[-1,1]之间。
反正切函数1
double atan(double x) ; //x为弧度,返回x的反正切arctan(x)值
参数x可以任意取值。
反正切函数2
double atan2(double y,double x);//返回的是原点到(x,y)的方位角