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
*/