| 1 |
'\" t |
| 2 |
.\" Copyright 1993 David Metcalfe ([email protected]) |
| 3 |
.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk |
| 4 |
.\" <[email protected]> |
| 5 |
.\" |
| 6 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 7 |
.\" |
| 8 |
.\" References consulted: |
| 9 |
.\" Linux libc source code |
| 10 |
.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) |
| 11 |
.\" 386BSD man pages |
| 12 |
.\" Modified 1993-07-24 by Rik Faith ([email protected]) |
| 13 |
.\" Modified 1995-08-14 by Arnt Gulbrandsen <[email protected]> |
| 14 |
.\" Modified 2002-07-27 by Walter Harms |
| 15 |
.\" ([email protected]) |
| 16 |
.\" |
| 17 |
.TH log 3 2024-05-02 "Linux man-pages 6.9.1" |
| 18 |
.SH NAME |
| 19 |
log, logf, logl \- natural logarithmic function |
| 20 |
.SH LIBRARY |
| 21 |
Math library |
| 22 |
.RI ( libm ", " \-lm ) |
| 23 |
.SH SYNOPSIS |
| 24 |
.nf |
| 25 |
.B #include <math.h> |
| 26 |
.P |
| 27 |
.BI "double log(double " x ); |
| 28 |
.BI "float logf(float " x ); |
| 29 |
.BI "long double logl(long double " x ); |
| 30 |
.fi |
| 31 |
.P |
| 32 |
.RS -4 |
| 33 |
Feature Test Macro Requirements for glibc (see |
| 34 |
.BR feature_test_macros (7)): |
| 35 |
.RE |
| 36 |
.P |
| 37 |
.BR logf (), |
| 38 |
.BR logl (): |
| 39 |
.nf |
| 40 |
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
| 41 |
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE |
| 42 |
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE |
| 43 |
.fi |
| 44 |
.SH DESCRIPTION |
| 45 |
These functions return the natural logarithm of |
| 46 |
.IR x . |
| 47 |
.SH RETURN VALUE |
| 48 |
On success, these functions return the natural logarithm of |
| 49 |
.IR x . |
| 50 |
.P |
| 51 |
If |
| 52 |
.I x |
| 53 |
is a NaN, |
| 54 |
a NaN is returned. |
| 55 |
.P |
| 56 |
If |
| 57 |
.I x |
| 58 |
is 1, the result is +0. |
| 59 |
.P |
| 60 |
If |
| 61 |
.I x |
| 62 |
is positive infinity, |
| 63 |
positive infinity is returned. |
| 64 |
.P |
| 65 |
If |
| 66 |
.I x |
| 67 |
is zero, |
| 68 |
then a pole error occurs, and the functions return |
| 69 |
.RB \- HUGE_VAL , |
| 70 |
.RB \- HUGE_VALF , |
| 71 |
or |
| 72 |
.RB \- HUGE_VALL , |
| 73 |
respectively. |
| 74 |
.P |
| 75 |
If |
| 76 |
.I x |
| 77 |
is negative (including negative infinity), then |
| 78 |
a domain error occurs, and a NaN (not a number) is returned. |
| 79 |
.SH ERRORS |
| 80 |
See |
| 81 |
.BR math_error (7) |
| 82 |
for information on how to determine whether an error has occurred |
| 83 |
when calling these functions. |
| 84 |
.P |
| 85 |
The following errors can occur: |
| 86 |
.TP |
| 87 |
Domain error: \fIx\fP is negative |
| 88 |
.I errno |
| 89 |
is set to |
| 90 |
.BR EDOM . |
| 91 |
An invalid floating-point exception |
| 92 |
.RB ( FE_INVALID ) |
| 93 |
is raised. |
| 94 |
.TP |
| 95 |
Pole error: \fIx\fP is zero |
| 96 |
.I errno |
| 97 |
is set to |
| 98 |
.BR ERANGE . |
| 99 |
A divide-by-zero floating-point exception |
| 100 |
.RB ( FE_DIVBYZERO ) |
| 101 |
is raised. |
| 102 |
.SH ATTRIBUTES |
| 103 |
For an explanation of the terms used in this section, see |
| 104 |
.BR attributes (7). |
| 105 |
.TS |
| 106 |
allbox; |
| 107 |
lbx lb lb |
| 108 |
l l l. |
| 109 |
Interface Attribute Value |
| 110 |
T{ |
| 111 |
.na |
| 112 |
.nh |
| 113 |
.BR log (), |
| 114 |
.BR logf (), |
| 115 |
.BR logl () |
| 116 |
T} Thread safety MT-Safe |
| 117 |
.TE |
| 118 |
.SH STANDARDS |
| 119 |
C11, POSIX.1-2008. |
| 120 |
.SH HISTORY |
| 121 |
C99, POSIX.1-2001. |
| 122 |
.P |
| 123 |
The variant returning |
| 124 |
.I double |
| 125 |
also conforms to |
| 126 |
SVr4, 4.3BSD, C89. |
| 127 |
.SH BUGS |
| 128 |
In glibc 2.5 and earlier, |
| 129 |
taking the |
| 130 |
.BR log () |
| 131 |
of a NaN produces a bogus invalid floating-point |
| 132 |
.RB ( FE_INVALID ) |
| 133 |
exception. |
| 134 |
.SH SEE ALSO |
| 135 |
.BR cbrt (3), |
| 136 |
.BR clog (3), |
| 137 |
.BR log10 (3), |
| 138 |
.BR log1p (3), |
| 139 |
.BR log2 (3), |
| 140 |
.BR sqrt (3) |