GAMMA 3M "630 MTG" ""

NAME
gamma - log gamma function

SYNOPSIS
#include <ccs/math.h>

double gamma (x)
double x;
extern int signgam;

DESCRIPTION
Gamma returns $ln ( | GAMMA ( ^ x ) | )$, where $GAMMA ( ^ x )$ is defined as $int from 0 to inf e sup { - t } t sup { x - 1 } dt$. The sign of is returned in the external integer signgam. The argument x may not be a non-positive integer.

The following C program fragment might be used to calculate Γ:

    if ((y = gamma(x)) > LN_MAXDOUBLE)
    	error();
    y = signgam * exp(y);

where LN_MAXDOUBLE is the least value that causes exp(3M) to return a range error, and is defined in the <ccs/values.h> header file.

DIAGNOSTICS
For non-negative integer arguments HUGE is returned, and errno is set to EDOM. A message indicating SING error is displayed.

If the correct value would overflow, gamma returns HUGE and sets errno to ERANGE.

These error-handling procedures may be changed with the function matherr(3M).

SEE ALSO
exp(3M), matherr(3M), values(5).