C 库函数 - log()

C 语言教程 · 2019-02-23 08:57:58

描述

C 库函数 double log(double x) 返回 x 的自然对数(基数为 e 的对数)。

声明

下面是 log() 函数的声明。

double log(double x)

参数

  • x -- 浮点值。

返回值

该函数返回 x 的自然对数。

实例

下面的实例演示了 log() 函数的用法。

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

int main ()
{
   double x, ret;
   x = 2.7;

   /* 计算 log(2.7) */
   ret = log(x);
   printf("log(%lf) = %lf", x, ret);
   
   return(0);
}

让我们编译并运行上面的程序,这将产生以下结果:

log(2.700000) = 0.993252

点击查看所有 C 语言教程 文章: https://www.codercto.com/courses/l/17.html

查看所有标签

Algorithms and Theory of Computation Handbook

Algorithms and Theory of Computation Handbook

Mikhail J. Atallah (Editor) / CRC-Press / 1998-09-30 / USD 94.95

Book Description This comprehensive compendium of algorithms and data structures covers many theoretical issues from a practical perspective. Chapters include information on finite precision issues......一起来看看 《Algorithms and Theory of Computation Handbook》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具