TGAMMA(3POSIX)
πΈ PROLOG πΈ
ok so first things first bestie β this page is part of the POSIX Programmer's Manual, and we're vibing with TGAMMA(3POSIX) today π
Heads up tho: the Linux implementation of this interface may differ (so go peek at the matching Linux manual page for the deets on Linux behavior), or honestly the interface may not even be implemented on Linux at all. π
β¨ NAME β¨
tgamma, tgammaf, tgammal β compute gamma() function π
π¦ SYNOPSIS π¦
#include <math.h>
double tgamma(double x);
float tgammaf(float x);
long double tgammal(long double x);
π DESCRIPTION π
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 β this volume of POSIX.1β2017 defers to the ISO C standard, periodt.
These functions shall compute Ξ(x), where Ξ(x) is defined as:
β«e^ βtt^ xβ1dt
Now, if you're an application that wants to check for error situations (iconic behavior honestly), you should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. Then on return: if errno is non-zero, or if fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred. π
π RETURN VALUE π
Upon successful completion, these functions shall return the gamma of x. slay.
- If
xis a negative integer, a domain error may occur, and either aNaN(if supported) or an implementation-defined value shall be returned. On systems that support the IEC 60559 Floating-Point option, a domain error shall occur and aNaNshall be returned. π€ - If
xisΒ±0,tgamma(),tgammaf(), andtgammal()shall returnΒ±HUGE_VAL,Β±HUGE_VALF, andΒ±HUGE_VALL, respectively. On systems that support the IEC 60559 Floating-Point option, a pole error shall occur; otherwise, a pole error may occur. - If the correct value would cause overflow, a range error shall occur and
tgamma(),tgammaf(), andtgammal()shall returnΒ±HUGE_VAL,Β±HUGE_VALF, orΒ±HUGE_VALL, respectively, with the same sign as the correct value of the function. - If the correct value would cause underflow, and is not representable, a range error may occur, and
tgamma(),tgammaf(), andtgammal()shall return0.0, or (if IEC 60559 Floating-Point is not supported) an implementation-defined value no greater in magnitude thanDBL_MIN,FLT_MIN, andLDBL_MIN, respectively. - If the correct value would cause underflow, and is representable, a range error may occur and the correct value shall be returned. π«Ά
- If
xis subnormal and1/xis representable,1/xshould be returned. - If
xisNaN, aNaNshall be returned. - If
xis+Inf,xshall be returned. - If
xis-Inf, a domain error shall occur, and aNaNshall be returned. π
π₯ ERRORS π₯
These functions shall fail if:
- Domain Error β the value of
xis a negative integer, orxis-Inf.- If the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[EDOM]. If the integer expression(math_errhandling & MATH_ERREXCEPT)is non-zero, then the invalid floating-point exception shall be raised.
- If the integer expression
- Pole Error β the value of
xis 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.
- If the integer expression
- Range Error β the value 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.
- If the integer expression
These functions may fail if:
- Domain Error β the value of
xis a negative integer.- If the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[EDOM]. If the integer expression(math_errhandling & MATH_ERREXCEPT)is non-zero, then the invalid floating-point exception shall be raised.
- If the integer expression
- Pole Error β the value of
xis 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.
- If the integer expression
- Range Error β the result underflows.
- 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 underflow floating-point exception shall be raised.
- If the integer expression
The following sections are informative. π
π EXAMPLES π
None.
not me giving you zero examples π that's literally what it says tho
π§ 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. no cap.
π RATIONALE π
This function is named tgamma() specifically to avoid conflicts with the historical gamma() and lgamma() functions. iykyk β name collisions are the villain of every story. π€
π FUTURE DIRECTIONS π
It is possible that the error response for a negative integer argument may be changed to a pole error and a return value of Β±Inf. so stay tuned bestie, plot twist pending π
β SEE ALSO β
feclearexcept()fetestexcept()lgamma()
And from the Base Definitions volume of POSIX.1β2017: Section 4.20, Treatment of Error Conditions for Mathematical Functions, and <math.h>. π
π COPYRIGHT π
ok legal bestie moment, gotta keep this exact because it's the law fr fr:
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 was IEEE/The Open Group, 2017 β TGAMMA(3POSIX) β signing off, 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