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