lgamma, lgammaf, lgammal, lgammad32, lgammad64, and lgammad128 Subroutine

Purpose

Computes the log gamma.

Syntax

#include <math.h>

extern int signgam;

double lgamma (x)
double x;

float lgammaf (x)
float x;

long double lgammal (x)
long double x;
_Decimal32 lgammad32 (x)
_Decimal32 x;

_Decimal64 lgammad64 (x)
_Decimal64 x;

_Decimal128 lgammad128 (x)
_Decimal128 x;

Description

The sign of Gamma ( x) is returned in the external integer signgam for the lgamma, lgammaf, and lgammal subroutines.

The lgamma, lgammaf, and lgammal subroutines are not reentrant. A function that is not required to be reentrant is not required to be thread-safe.

An application wishing to check for error situations should set the errno global variable to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these subroutines. Upon return, if errno is nonzero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is nonzero, an error has occurred.

Parameters

Item Description
x Specifies the value to be computed.

Return Values

Upon successful completion, the lgamma, lgammaf, lgammal, lgammad32, lgammad64, and lgammad128 subroutines return the logarithmic gamma of x.

If x is a non-positive integer, a pole error shall occur and the lgamma, lgammaf, lgammal, lgammad32, lgammad64, and lgammad128 subroutines will return +HUGE_VAL, +HUGE_VALF, +HUGE_VALL, +HUGE_VAL_D32, +HUGE_VAL_D64, and +HUGE_VAL_D128 respectively.

If the correct value would cause overflow, a range error shall occur and the lgamma, lgammaf, lgammal, lgammad32, lgammad64, and lgammad128 subroutines will return ±HUGE_VAL, ±HUGE_VALF, ±HUGE_VALL, +HUGE_VAL_D32, +HUGE_VAL_D64, and +HUGE_VAL_D128 respectively.

If x is NaN, a NaN is returned.

If x is 1 or 2, +0 is returned.

If x is ±Inf, +Inf is returned.