lgamma(3) - NetBSD Manual Pages

Command: Section: Arch: Collection:  
LGAMMA(3)               NetBSD Library Functions Manual              LGAMMA(3)

lgamma, lgammaf, lgammal, lgamma_r, lgammaf_r, lgammal_r, gamma, gammaf, gamma_r, gammaf_r, tgamma, tgammaf, tgammal -- log gamma function
Math Library (libm, -lm)
#include <math.h> extern int signgam; double lgamma(double x); float lgammaf(float x); long double lgammal(long double x); double lgamma_r(double x, int *sign); float lgammaf_r(float x, int *sign); long double lgammal_r(long double x, int *sign); double gamma(double x); float gammaf(float x); double gamma_r(double x, int *sign); float gammaf_r(float x, int *sign); double tgamma(double x); float tgammaf(float x); long double tgammal(long double x);
lgamma(x) returns ln||(x)|. The external integer signgam returns the sign of |(x). lgamma_r() is a reentrant interface that performs identically to lgamma(), differing in that the sign of |(x) is stored in the location pointed to by the sign argument and signgam is not modified. The tgamma(x) and tgammaf(x) functions return |(x), with no effect on signgam. gamma(), gammaf(), gamma_r(), and gammaf_r() are deprecated aliases for lgamma(), lgammaf(), lgamma_r(), and lgammaf_r(), respectively.
Do not use the expression ``signgam*exp(lgamma(x))'' to compute g := |(x). Instead use a program like this (in C): lg = lgamma(x); g = signgam*exp(lg); Only after lgamma() has returned can signgam be correct.
lgamma() returns appropriate values unless an argument is out of range. Overflow will occur for sufficiently large positive values, and non-posi- tive integers. For large non-integer negative values, tgamma() will underflow. On the VAX, the reserved operator is returned, and errno is set to ERANGE.
The lgamma function appeared in 4.3BSD. The tgamma() function appeared in NetBSD 6.0. NetBSD 10.99 January 24, 2024 NetBSD 10.99
Powered by man-cgi (2024-03-20). Maintained for NetBSD by Kimmo Suominen. Based on man-cgi by Panagiotis Christias.