ADC Home > Reference Library > Technical Q&As > Porting > Carbon >
Technical Q&A QA1143
The Gamma function in the Mac OS X 10.2 Math Library
|
Q:
There are a number of functions described in /usr/include/math.h that deal
with the gamma function. Which one should I use?
A:
Going forward, the tgamma and lgamma functions provide the
approximations required by the C99 standard. You should use them in new code. The
function named gamma offers backward compatability to MacOS 9 and
CarbonLib programs.
Historically, the MacOS 9 math libraries (and CarbonLib ) have
exported a routine named gamma() that approximates the Gamma function. The many variants
of Unix (BSD, Posix, etc.) have offered routines named lgamma and
gamma both approximating the log of the absolute value of the Gamma
function, rather than the value of the Gamma function in its natural scale.
In Mac OS X there are three implementations of the Gamma function:
- The new
tgamma function that approximates
the Gamma function in its natural scale.
- The BSD
lgamma function that approximates ln( | Gamma | ) .
- The Mac OS 9 gamma function that approximates the
Gamma function (depricated). This function preserves the MacOS9/CarbonLib
gamma semantics, but its use is deprecated. New applications
should call the modern tgamma function.
Note:
Unix applications that refer to the gamma function and
expect to obtain the value ln( | Gamma | ) will need to be modified
to reference the BSD lgamma function.
|
[Aug 27 2002]
|
We’re sorry, an error has occurred.
Please try submitting your feedback later.
Thank you for providing feedback!
Your input helps improve our developer documentation.