LGAMMA(3POSIX)
π LGAMMA(3POSIX) β log gamma function π
okay bestie, we're in the POSIX Programmer's Manual, and this page is about the log gamma function (plus its float and long double glow-ups). Pull up a chair, grab a boba, and let's get into it β¨
πΈ PROLOG πΈ
This manual page is part of the POSIX Programmer's Manual. Heads up though: the Linux implementation of this interface may differ (so go consult the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface may not even be implemented on Linux at all. Not me being dramatic, that's just literally what it says π«Ά
π NAME π
lgamma, lgammaf, lgammal, signgam β log gamma function
β¨ SYNOPSIS β¨
#include <math.h>
double lgamma(double x);
float lgammaf(float x);
long double lgammal(long double x);
extern int signgam;
π DESCRIPTION π
So the functionality described on this reference page is aligned with the ISO C standard. If anything here conflicts with the ISO C standard, that conflict is unintentional β no cap. This volume of POSIX.1β2017 defers to the ISO C standard, periodt.
These functions shall compute:
log_e βΞ(x)β where Ξ(x) is defined as β«e^ βtt^ xβ1dt.
The argument x need not be a non-positive integer (Ξ(x) is defined over the reals, except the non-positive integers). slay.
IfxisNaN,-Inf, or a negative integer, the value ofsigngamis unspecified. so don't count on it, bestie π
These functions need not be thread-safe. iykyk.
An application wishing to check for error situations should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. On return, if errno is non-zero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred. that's your vibe check β
π RETURN VALUE π
Upon successful completion, these functions shall return the logarithmic gamma of x. main character behavior honestly.
- If
xis a non-positive integer, a pole error shall occur andlgamma(),lgammaf(), andlgammal()shall return+HUGE_VAL,+HUGE_VALF, and+HUGE_VALL, respectively. π - If the correct value would cause overflow, a range error shall occur and
lgamma(),lgammaf(), andlgammal()shall returnΒ±HUGE_VAL,Β±HUGE_VALF, andΒ±HUGE_VALL(having the same sign as the correct value), respectively. - If
xisNaN, aNaNshall be returned. - If
xis1or2,+0shall be returned. cute. - If
xisΒ±Inf,+Infshall be returned.
π₯ ERRORS π₯
These functions shall fail if:
Pole Error
The x argument is a negative integer or zero.
- If the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[ERANGE]. - If the integer expression
(math_errhandling & MATH_ERREXCEPT)is non-zero, then the divide-by-zero floating-point exception shall be raised.
Range Error
The result overflows.
- If the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[ERANGE]. - If the integer expression
(math_errhandling & MATH_ERREXCEPT)is non-zero, then the overflow floating-point exception shall be raised.
The following sections are informative. (so like, the tea below is extra, not the law π)
π EXAMPLES π
None. β yeah, nothing here, bestie. moving on π¦
π APPLICATION USAGE π
On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other, but at least one of them must be non-zero. like, one of them has to show up to the party, okay? β¨
π§ RATIONALE π§
None.
β FUTURE DIRECTIONS β
None.
π SEE ALSO π
exp()feclearexcept()fetestexcept()isnan()
Also, from The Base Definitions volume of POSIX.1β2017: Section 4.20, Treatment of Error Conditions for Mathematical Functions, and <math.h>. go read those, bestie, they're iconic π
πΈ COPYRIGHT πΈ
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! π this little love letter came to you from IEEE/The Open Group, 2017, and the manual page is literally called LGAMMA(3POSIX). go forth and compute your log gammas responsibly, mwah πβ¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms