ln, lg, log在C中的应用

您所在的位置:网站首页 c语言log函数怎么定义 ln, lg, log在C中的应用

ln, lg, log在C中的应用

2024-06-05 07:47| 来源: 网络整理| 查看: 265

在C语言中定义的函数和数学上定义的函数有所区别:C语言中只定义的两个函数: (1)y=log(double x) (2)y=log10(double x) 第(1)个代表数学式中的ln,第(2)个代表数学式中的 lg;而数学上要求loga(b) (a不为e和10),可用换底公式表示为log(b)/log(a)(或者 log10(b)/log10(a))。注意一点的是要包含头文件math.h

函数为:

extern _ARMABI double log(double /*x*/); /* computes the natural logarithm of x. A domain error occurs if the */ /* argument is negative, and -HUGE_VAL is returned. A range error occurs */ /* if the argument is zero. */ /* Returns: the natural logarithm. */ /* if range error; -HUGE_VAL is returned. */ extern _ARMABI double log10(double /*x*/); /* computes the base-ten logarithm of x. A domain error occurs if the */ /* argument is negative. A range error occurs if the argument is zero. */ /* Returns: the base-ten logarithm. */

备注:有时候keil中即使包含math.h头文件在使用依然会出现错误数据的情况(计算为异常0值);则需要在要调用改数学函数文件中包含: extern _ARMABI double log(double /x/); extern _ARMABI double log10(double /x/);



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3