log() — 自然対数の計算

形式

#include <math.h>
double log(double x);

言語レベル

ANSI

スレッド・セーフ

はい

説明

log() 関数は、 xの自然対数 (底 e) を計算します。

戻り値

log() 関数は、計算された値を返します。 x が負の場合、 log()errnoEDOM に設定し、値 -HUGE_VALを戻す可能性があります。 x がゼロの場合、 log() は値 -HUGE_VALを戻し、 errnoERANGEに設定する可能性があります。

この例では、1000.0 の対数を計算します。
#include <math.h>
#include <stdio.h>
 
int main(void)
{
   double x = 1000.0, y;
 
   y = log(x);
 
   printf("The natural logarithm of %lf is %lf\n", x, y);
}
 
/********************  Output should be similar to:  **************
 
The natural logarithm of 1000.000000 is 6.907755
*/

関連情報