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(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 ||
20       _ISOC99_SOURCE; or cc -std=c99
21

DESCRIPTION

23       The log() function returns the natural logarithm of x.
24

RETURN VALUE

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

ERRORS

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

CONFORMING TO

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

BUGS

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

SEE ALSO

63       cbrt(3), clog(3), log1p(3), sqrt(3)
64

COLOPHON

66       This  page  is  part of release 3.22 of the Linux man-pages project.  A
67       description of the project, and information about reporting  bugs,  can
68       be found at http://www.kernel.org/doc/man-pages/.
69
70
71
72                                  2008-08-10                            LOG(3)
Impressum