Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC Numerics / Part 2 - The PowerPC Numerics C Implementation
Chapter 10 - Transcendental Functions / Error and Gamma Functions


gamma

You can use the gamma function to perform Gamma(x) .

double_t gamma (double_t x);
x
Any positive floating-point number.
DESCRIPTION
The gamma function performs Gamma(x) .

gamma(x) = Gamma(x) = 0 e-ttx+-1dt

The gamma function reaches overflow very fast as x approaches + . For large values, use the lgamma function (described in the next section) instead.

EXCEPTIONS
When x is finite and nonzero, either the result of gamma(x) is exact or it raises one of the following exceptions:

  • inexact (if the result must be rounded or an overflow occurs)
  • invalid (if x is a negative integer)
  • overflow (if the result is outside the range of the data type)

SPECIAL CASES
Table 10-37 shows the results when the argument to the gamma function is a zero, a NaN, or an Infinity, plus other special cases for the gamma function.
Special cases for the gamma function
OperationResultExceptions raised
gamma(x) for negative integer x NaNInvalid
gamma(+0) NaNInvalid
gamma(-0) NaNInvalid
gamma(NaN) NaNNone[61]
gamma(+ ) + Overflow
gamma(- ) NaNInvalid

EXAMPLES
z = gamma(-1.0);  /* z = NAN. The invalid exception is raised. */
z = gamma(6);     /* z = 120 */

[61] If the NaN is a signaling NaN, the invalid exception is raised.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996