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           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
21               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
22               || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
23

DESCRIPTION

25       These functions return 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 oc‐
40       curs, 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

ATTRIBUTES

57       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
58       tributes(7).
59
60       ┌────────────────────────────────────────────┬───────────────┬─────────┐
61Interface                                   Attribute     Value   
62       ├────────────────────────────────────────────┼───────────────┼─────────┤
63log(), logf(), logl()                       │ Thread safety │ MT-Safe │
64       └────────────────────────────────────────────┴───────────────┴─────────┘
65

CONFORMING TO

67       C99, POSIX.1-2001, POSIX.1-2008.
68
69       The variant returning double also conforms to SVr4, 4.3BSD, C89.
70

BUGS

72       In  glibc  2.5  and earlier, taking the log() of a NaN produces a bogus
73       invalid floating-point (FE_INVALID) exception.
74

SEE ALSO

76       cbrt(3), clog(3), log10(3), log1p(3), log2(3), sqrt(3)
77

COLOPHON

79       This page is part of release 5.12 of the Linux  man-pages  project.   A
80       description  of  the project, information about reporting bugs, and the
81       latest    version    of    this    page,    can     be     found     at
82       https://www.kernel.org/doc/man-pages/.
83
84
85
86                                  2021-03-22                            LOG(3)
Impressum