C语言 如何在 C 编程中使用 Ln 函数?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34205208/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 12:15:37  来源:igfitidea点击:

How can you use Ln function in C programing?

c

提问by P. Balech

Header file math.h is for mathematical functions like cos,sin, tan.. But how to write the ln function and not log?

头文件 math.h 是用于 cos,sin, tan 等数学函数的.. 但是如何编写 ln 函数而不是 log 呢?

回答by aschepler

The C function logis the natural logarithm, which mathematicians usually write as "ln".

C函数log是自然对数,数学家通常写成“ln”。

The C function log10is the logarithm base 10, which is sometimes written "log".

C函数log10是以10为底的对数,有时写成“log”。

回答by Paulo

Remember math at school: logA_B = logA_C/logB_C

记住学校的数学:logA_B = logA_C/logB_C

回答by n. 'pronouns' m.

double ln(double x) { return log(x); }

Or in a pinch

或者在紧要关头

#define ln(x) log(x)