1LGAMMA(3P) POSIX Programmer's Manual LGAMMA(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 lgamma, lgammaf, lgammal, signgam — log gamma function
13
15 #include <math.h>
16
17 double lgamma(double x);
18 float lgammaf(float x);
19 long double lgammal(long double x);
20 extern int signgam;
21
23 The functionality described on this reference page is aligned with the
24 ISO C standard. Any conflict between the requirements described here
25 and the ISO C standard is unintentional. This volume of POSIX.1‐2017
26 defers to the ISO C standard.
27
28 These functions shall compute log_e │Γ(x)│ where Γ(x) is defined as ∞0∫e^
29 −tt^ x−1dt. The argument x need not be a non-positive integer (Γ(x) is
30 defined over the reals, except the non-positive integers).
31
32 If x is NaN, -Inf, or a negative integer, the value of signgam is
33 unspecified.
34
35 These functions need not be thread-safe.
36
37 An application wishing to check for error situations should set errno
38 to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these
39 functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
40 FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
41 occurred.
42
44 Upon successful completion, these functions shall return the logarith‐
45 mic gamma of x.
46
47 If x is a non-positive integer, a pole error shall occur and lgamma(),
48 lgammaf(), and lgammal() shall return +HUGE_VAL, +HUGE_VALF, and
49 +HUGE_VALL, respectively.
50
51 If the correct value would cause overflow, a range error shall occur
52 and lgamma(), lgammaf(), and lgammal() shall return ±HUGE_VAL,
53 ±HUGE_VALF, and ±HUGE_VALL (having the same sign as the correct value),
54 respectively.
55
56 If x is NaN, a NaN shall be returned.
57
58 If x is 1 or 2, +0 shall be returned.
59
60 If x is ±Inf, +Inf shall be returned.
61
63 These functions shall fail if:
64
65 Pole Error The x argument is a negative integer or zero.
66
67 If the integer expression (math_errhandling & MATH_ERRNO)
68 is non-zero, then errno shall be set to [ERANGE]. If the
69 integer expression (math_errhandling & MATH_ERREXCEPT) is
70 non-zero, then the divide-by-zero floating-point exception
71 shall be raised.
72
73 Range Error The result overflows.
74
75 If the integer expression (math_errhandling & MATH_ERRNO)
76 is non-zero, then errno shall be set to [ERANGE]. If the
77 integer expression (math_errhandling & MATH_ERREXCEPT) is
78 non-zero, then the overflow floating-point exception shall
79 be raised.
80
81 The following sections are informative.
82
84 None.
85
87 On error, the expressions (math_errhandling & MATH_ERRNO) and
88 (math_errhandling & MATH_ERREXCEPT) are independent of each other, but
89 at least one of them must be non-zero.
90
92 None.
93
95 None.
96
98 exp(), feclearexcept(), fetestexcept(), isnan()
99
100 The Base Definitions volume of POSIX.1‐2017, Section 4.20, Treatment of
101 Error Conditions for Mathematical Functions, <math.h>
102
104 Portions of this text are reprinted and reproduced in electronic form
105 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
106 table Operating System Interface (POSIX), The Open Group Base Specifi‐
107 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
108 Electrical and Electronics Engineers, Inc and The Open Group. In the
109 event of any discrepancy between this version and the original IEEE and
110 The Open Group Standard, the original IEEE and The Open Group Standard
111 is the referee document. The original Standard can be obtained online
112 at http://www.opengroup.org/unix/online.html .
113
114 Any typographical or formatting errors that appear in this page are
115 most likely to have been introduced during the conversion of the source
116 files to man page format. To report such errors, see https://www.ker‐
117 nel.org/doc/man-pages/reporting_bugs.html .
118
119
120
121IEEE/The Open Group 2017 LGAMMA(3P)