1LOG(3)                     Linux Programmer's Manual                    LOG(3)
2
3
4

NAME

6       log, logf, logl - natural logarithmic function
7

SYNOPSIS

9       #include <math.h>
10
11       double log(double x);
12       float logf(float x);
13       long double logl(long double x);
14
15       Link with -lm.
16
17   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19       logf(), logl():
20           _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 ||
21           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L;
22           or cc -std=c99
23

DESCRIPTION

25       The log() function returns the natural logarithm of x.
26

RETURN VALUE

28       On success, these functions return the natural logarithm of x.
29
30       If x is a NaN, a NaN is returned.
31
32       If x is 1, the result is +0.
33
34       If x is positive infinity, positive infinity is returned.
35
36       If x is zero, then a  pole  error  occurs,  and  the  functions  return
37       -HUGE_VAL, -HUGE_VALF, or -HUGE_VALL, respectively.
38
39       If  x  is  negative  (including negative infinity), then a domain error
40       occurs, and a NaN (not a number) is returned.
41

ERRORS

43       See math_error(7) for information on how to determine whether an  error
44       has occurred when calling these functions.
45
46       The following errors can occur:
47
48       Domain error: x is negative
49              errno  is  set  to  EDOM.   An  invalid floating-point exception
50              (FE_INVALID) is raised.
51
52       Pole error: x is zero
53              errno is set to ERANGE.  A divide-by-zero floating-point  excep‐
54              tion (FE_DIVBYZERO) is raised.
55

CONFORMING TO

57       C99, POSIX.1-2001.  The variant returning double also conforms to SVr4,
58       4.3BSD, C89.
59

BUGS

61       In glibc 2.5 and earlier, taking the log() of a NaN  produces  a  bogus
62       invalid floating-point (FE_INVALID) exception.
63

SEE ALSO

65       cbrt(3), clog(3), log10(3), log1p(3), log2(3), sqrt(3)
66

COLOPHON

68       This  page  is  part of release 3.53 of the Linux man-pages project.  A
69       description of the project, and information about reporting  bugs,  can
70       be found at http://www.kernel.org/doc/man-pages/.
71
72
73
74                                  2010-09-20                            LOG(3)
Impressum