常用的matn函数
fabs(double x)该函数用于对 double类型变量取绝对值
floor(double x)和ceil(double x)用于对double 型变量的向下取整和向上取整,返回类型为double型,
pow(double r,double p)该函数用于返回r的P次幂,要求r和p都是double型
sqrt(double x)
log(double x)
round(double x)用于将double型变量四舍五入
#include<stdio.h>
#include<math.h>
int main(){
double db1=round(3.40);
double db2=round(3.45);
double db3=round(3.50);
printf("%d,%d,%d\n",(int)db1,(int)db2,(int)db3);
return 0;
}
输出结果:3,3,4