]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/lgamma.3
feature_test_macros.7: Clarify some _ISOC99_SOURCE / _DEFAULT_SOURCE details
[thirdparty/man-pages.git] / man3 / lgamma.3
CommitLineData
fea681da 1.\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
9981365e
MK
2.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3.\" <mtk.manpages@gmail.com>
2297bf0e 4.\"
38f20bb9 5.\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
fea681da 6.\" Distributed under GPL
38f20bb9 7.\" %%%LICENSE_END
9981365e 8.\"
fea681da
MK
9.\" based on glibc infopages
10.\"
c73595c2 11.TH LGAMMA 3 2015-04-19 "" "Linux Programmer's Manual"
fea681da 12.SH NAME
cc4615cc
MK
13lgamma, lgammaf, lgammal, lgamma_r, lgammaf_r, lgammal_r, signgam \-
14log gamma function
fea681da
MK
15.SH SYNOPSIS
16.nf
17.B #include <math.h>
18.sp
19.BI "double lgamma(double " x );
20.br
21.BI "float lgammaf(float " x );
22.br
23.BI "long double lgammal(long double " x );
24.sp
25.BI "double lgamma_r(double " x ", int *" signp );
26.br
27.BI "float lgammaf_r(float " x ", int *" signp );
28.br
29.BI "long double lgammal_r(long double " x ", int *" signp );
30d2db8b 30.sp
cc4615cc 31.BI "extern int " signgam ;
fea681da
MK
32.fi
33.sp
cc4615cc
MK
34Link with \fI\-lm\fP.
35.sp
36.in -4n
37Feature Test Macro Requirements for glibc (see
38.BR feature_test_macros (7)):
39.in
40.sp
41.ad l
bb4abad3 42.BR lgamma ():
61d70a99 43.RS 4
45babd38 44_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE || _ISOC99_SOURCE ||
e464f054 45_POSIX_C_SOURCE\ >=\ 200112L
61d70a99
MK
46.br
47or
bb4abad3 48.I cc\ -std=c99
61d70a99 49.RE
bb4abad3 50.br
cc4615cc
MK
51.BR lgammaf (),
52.BR lgammal ():
61d70a99 53.RS 4
e464f054
MK
54_BSD_SOURCE || _SVID_SOURCE || _ISOC99_SOURCE ||
55_POSIX_C_SOURCE\ >=\ 200112L
61d70a99
MK
56.br
57or
cc4615cc 58.I cc\ -std=c99
c8e66e31 59.RE
cc4615cc
MK
60.BR lgamma_r (),
61.BR lgammaf_r (),
62.BR lgammal_r ():
c8e66e31 63.RS 4
cc4615cc 64_BSD_SOURCE || _SVID_SOURCE
c8e66e31 65.RE
cc4615cc 66.IR signgam :
c8e66e31 67.RS 4
cc4615cc 68_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE
c8e66e31 69.RE
cc4615cc 70.ad b
fea681da
MK
71.SH DESCRIPTION
72For the definition of the Gamma function, see
73.BR tgamma (3).
74.PP
60a90ecd 75The
5600f73a
MK
76.BR lgamma (),
77.BR lgammaf (),
78and
79.BR lgammal ()
80functions return the natural logarithm of
fea681da
MK
81the absolute value of the Gamma function.
82The sign of the Gamma function is returned in the
022671eb
MK
83external integer
84.I signgam
85declared in
fea681da
MK
86.IR <math.h> .
87It is 1 when the Gamma function is positive or zero, \-1
88when it is negative.
89.PP
90Since using a constant location
91.I signgam
60a90ecd 92is not thread-safe, the functions
853a2aba
MK
93.BR lgamma_r (),
94.BR lgammaf_r (),
95and
96.BR lgammal_r ()
97have been introduced; they return the sign via the argument
fea681da 98.IR signp .
bb4abad3
MK
99.SH RETURN VALUE
100On success, these functions return the natural logarithm of Gamma(x).
101
102If
103.I x
104is a NaN, a NaN is returned.
105
106If
107.I x
108is 1 or 2, +0 is returned.
109
110If
111.I x
112is positive infinity or negative infinity,
113positive infinity is returned.
114
115If
116.I x
657316c0 117is a nonpositive integer,
efe294cb 118a pole error occurs,
bb4abad3
MK
119and the functions return
120.RB + HUGE_VAL ,
121.RB + HUGE_VALF ,
122or
123.RB + HUGE_VALL ,
124respectively.
125
126If the result overflows,
efe294cb 127a range error occurs,
bb4abad3
MK
128.\" e.g., lgamma(DBL_MAX)
129and the functions return
2f0af33b 130.BR HUGE_VAL ,
bb4abad3
MK
131.BR HUGE_VALF ,
132or
133.BR HUGE_VALL ,
134respectively, with the correct mathematical sign.
fea681da 135.SH ERRORS
bb4abad3
MK
136See
137.BR math_error (7)
138for information on how to determine whether an error has occurred
139when calling these functions.
140.PP
141The following errors can occur:
142.TP
657316c0 143Pole error: \fIx\fP is a nonpositive integer
fea681da 144.I errno
bb4abad3 145is set to
385cf745 146.BR ERANGE
bb4abad3
MK
147(but see BUGS).
148A divide-by-zero floating-point exception
149.RB ( FE_DIVBYZERO )
150is raised.
151.TP
152Range error: result overflow
fea681da 153.I errno
bb4abad3
MK
154is set to
155.BR ERANGE .
156An overflow floating-point exception
157.RB ( FE_OVERFLOW )
158is raised.
159.\" glibc (as at 2.8) also supports an inexact
160.\" exception for various cases.
47297adb 161.SH CONFORMING TO
637d38e3
MK
162The
163.BR lgamma ()
9a0216ac 164functions are specified in C99, POSIX.1-2001, and POSIX.1-2008.
637d38e3 165.I signgam
9a0216ac 166is specified in POSIX.1-2001 and POSIX.1-2008, but not in C99.
637d38e3
MK
167The
168.BR lgamma_r ()
c8f2dd47 169functions are nonstandard, but present on several other systems.
bb4abad3 170.SH BUGS
4e836144 171In glibc 2.9 and earlier,
707a25b2
MK
172.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6777
173when a pole error occurs,
bb4abad3
MK
174.I errno
175is set to
176.BR EDOM ;
707a25b2 177instead of the POSIX-mandated
bb4abad3 178.BR ERANGE .
707a25b2 179Since version 2.10, glibc does the right thing.
47297adb 180.SH SEE ALSO
fea681da 181.BR tgamma (3)