数学函数

头文件math.h中含有大量的数学函数声明。

数学函数

-----------------------------------------------------------------------------------------------------

函数                                      运算

-----------------------------------------------------------------------------------------------------

floor(x)                                 返回不大于x的double类型最大整数值

ceil(x)                                 返回不小于x的double类型最小整数值

fabs(x)                                   返回x的绝对值

log(x)                                  返回x的(以e为底)自然对数

log10(x)                                返回x以10为底的对数

exp(x)                                   返回e的x次的值

sqrt(x)                                   返回x的平方根

pow(x,y)                               返回x的y次

-------------------------------------------------------------------------------------------------------

   测试的程序如下:          

#include<stdio.h>
#include <math.h>


int main()
{
double x=2.5f;
double y=-2.5f;

printf("\n the floor is %lf  and %lf",floor(x),floor(y));
printf("\n the ceil is %lf  and %lf",ceil(x),ceil(y));
printf("\n the fabs is %lf  and %lf",fabs(x),fabs(y));
printf("\n the log is %lf  and %lf",log(x),log(100000));
printf("\n the log10 is %lf  and %lf",log10(x),log10(100000));
printf("\n the exp is %lf  and %lf",exp(x),exp(y));
printf("\n the sqrt is %lf  and %lf",sqrt(x),sqrt(100));

return 0;


}


运行的结果如下:

 the floor is 2.000000  and -3.000000
 the ceil is 3.000000  and -2.000000
 the fabs is 2.500000  and 2.500000
 the log is 0.916291  and 11.512925
 the log10 is 0.397940  and 5.000000
 the exp is 12.182494  and 0.082085
 the sqrt is 1.581139  and 10.000000

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值