1lgamma(3) Library Functions Manual lgamma(3)
2
3
4
6 lgamma, lgammaf, lgammal, lgamma_r, lgammaf_r, lgammal_r, signgam - log
7 gamma function
8
10 Math library (libm, -lm)
11
13 #include <math.h>
14
15 double lgamma(double x);
16 float lgammaf(float x);
17 long double lgammal(long double x);
18
19 double lgamma_r(double x, int *signp);
20 float lgammaf_r(float x, int *signp);
21 long double lgammal_r(long double x, int *signp);
22
23 extern int signgam;
24
25 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
26
27 lgamma():
28 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE
29 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
30 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
31
32 lgammaf(), lgammal():
33 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
34 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
35 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
36
37 lgamma_r(), lgammaf_r(), lgammal_r():
38 /* Since glibc 2.19: */ _DEFAULT_SOURCE
39 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
40
41 signgam:
42 _XOPEN_SOURCE
43 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
44 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
45
47 For the definition of the Gamma function, see tgamma(3).
48
49 The lgamma(), lgammaf(), and lgammal() functions return the natural
50 logarithm of the absolute value of the Gamma function. The sign of the
51 Gamma function is returned in the external integer signgam declared in
52 <math.h>. It is 1 when the Gamma function is positive or zero, -1 when
53 it is negative.
54
55 Since using a constant location signgam is not thread-safe, the func‐
56 tions lgamma_r(), lgammaf_r(), and lgammal_r() have been introduced;
57 they return the sign via the argument signp.
58
60 On success, these functions return the natural logarithm of Gamma(x).
61
62 If x is a NaN, a NaN is returned.
63
64 If x is 1 or 2, +0 is returned.
65
66 If x is positive infinity or negative infinity, positive infinity is
67 returned.
68
69 If x is a nonpositive integer, a pole error occurs, and the functions
70 return +HUGE_VAL, +HUGE_VALF, or +HUGE_VALL, respectively.
71
72 If the result overflows, a range error occurs, and the functions return
73 HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with the correct math‐
74 ematical sign.
75
77 See math_error(7) for information on how to determine whether an error
78 has occurred when calling these functions.
79
80 The following errors can occur:
81
82 Pole error: x is a nonpositive integer
83 errno is set to ERANGE (but see BUGS). A divide-by-zero float‐
84 ing-point exception (FE_DIVBYZERO) is raised.
85
86 Range error: result overflow
87 errno is set to ERANGE. An overflow floating-point exception
88 (FE_OVERFLOW) is raised.
89
91 lgamma()
92 lgammaf()
93 lgammal()
94 C11, POSIX.1-2008.
95
96 signgam
97 POSIX.1-2008.
98
99 lgamma_r()
100 lgammaf_r()
101 lgammal_r()
102 None.
103
105 lgamma()
106 lgammaf()
107 lgammal()
108 C99, POSIX.1-2001.
109
110 signgam
111 POSIX.1-2001.
112
113 lgamma_r()
114 lgammaf_r()
115 lgammal_r()
116 None.
117
119 In glibc 2.9 and earlier, when a pole error occurs, errno is set to
120 EDOM; instead of the POSIX-mandated ERANGE. Since glibc 2.10, glibc
121 does the right thing.
122
124 tgamma(3)
125
126
127
128Linux man-pages 6.05 2023-03-30 lgamma(3)