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 - 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
21
22 extern int signgam;
23
24
26 These functions shall compute
27
28
29 The argument x need not be a non-positive integer (Gamma(x) is defined
30 over the reals, except the non-positive integers).
31
32 The sign of Gamma(x) is returned in the external integer signgam.
33
34 These functions need not be reentrant. A function that is not required
35 to be reentrant is not required to 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
66 The x argument is a negative integer or zero.
67
68 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
69 then errno shall be set to [ERANGE]. If the integer expression
70 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the divide-by-
71 zero floating-point exception shall be raised.
72
73 Range Error
74 The result overflows.
75
76 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
77 then errno shall be set to [ERANGE]. If the integer expression
78 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the overflow
79 floating-point exception shall be raised.
80
81
82 The following sections are informative.
83
85 None.
86
88 On error, the expressions (math_errhandling & MATH_ERRNO) and
89 (math_errhandling & MATH_ERREXCEPT) are independent of each other, but
90 at least one of them must be non-zero.
91
93 None.
94
96 None.
97
99 exp(), feclearexcept(), fetestexcept(), isnan(), the Base Definitions
100 volume of IEEE Std 1003.1-2001, Section 4.18, Treatment of Error Condi‐
101 tions for Mathematical Functions, <math.h>
102
104 Portions of this text are reprinted and reproduced in electronic form
105 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
106 -- Portable Operating System Interface (POSIX), The Open Group Base
107 Specifications Issue 6, Copyright (C) 2001-2003 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
115
116IEEE/The Open Group 2003 LGAMMA(3P)