xref: /freebsd/lib/msun/man/log.3 (revision 9a14aa017b21c292740c00ee098195cd46642730)
1.\" Copyright (c) 2008-2010 David Schultz <das@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd December 5, 2010
28.Dt LOG 3
29.Os
30.Sh NAME
31.Nm log ,
32.Nm logf ,
33.Nm logl ,
34.Nm log10 ,
35.Nm log10f ,
36.Nm log2 ,
37.Nm log2f ,
38.Nm log1p ,
39.Nm log1pf
40.Nd logarithm functions
41.Sh LIBRARY
42.Lb libm
43.Sh SYNOPSIS
44.In math.h
45.Ft double
46.Fn log "double x"
47.Ft float
48.Fn logf "float x"
49.Ft double
50.Fn log10 "double x"
51.Ft float
52.Fn log10f "float x"
53.Ft double
54.Fn log2 "double x"
55.Ft float
56.Fn log2f "float x"
57.Ft double
58.Fn log1p "double x"
59.Ft float
60.Fn log1pf "float x"
61.Sh DESCRIPTION
62The
63.Fn log
64and
65.Fn logf
66functions compute the natural logarithm of
67.Fa x .
68.Pp
69The
70.Fn log10
71and
72.Fn log10f
73functions compute the logarithm base 10 of
74.Fa x ,
75while
76.Fn log2
77and
78.Fn log2f
79compute the logarithm base 2 of
80.Fa x .
81.Pp
82The
83.Fn log1p
84and
85.Fn log1pf
86functions compute the natural logarithm of
87.No "1 + x" .
88Computing the natural logarithm as
89.Li log1p(x)
90is more accurate than computing it as
91.Li log(1 + x)
92when
93.Fa x
94is close to zero.
95.Sh RETURN VALUES
96These functions return the requested logarithm; the logarithm of 1 is +0.
97An attempt to take the logarithm of \*(Pm0 results in a divide-by-zero
98exception, and -\*(If is returned.
99Otherwise, attempting to take the logarithm of a negative number
100results in an invalid exception and a return value of \*(Na.
101.Sh SEE ALSO
102.Xr exp 3 ,
103.Xr ilogb 3 ,
104.Xr math 3 ,
105.Xr pow 3
106.Sh STANDARDS
107The
108.Fn log ,
109.Fn logf ,
110.Fn log10 ,
111.Fn log10f ,
112.Fn log2 ,
113.Fn log2f ,
114.Fn log1p ,
115and
116.Fn log1pf
117functions conform to
118.St -isoC-99 .
119