Document (in a comment) the current (slightly broken) handling of special

values in more detail, and change the style of this comment to be closer
to fdlibm and C99:
- tgamma(-Inf) was undocumented and is wrong (+Inf, should be NaN)
- tgamma(negative integer) is as intended (+Inf) but not best for IEEE-754
  (NaN)
- tgamma(-0) was documented as being wrong (+Inf) but was correct (-Inf)
- documentation of setting of exceptions (overflow, etc.) was more
  complete here than in most of libm, but was further from matching
  the actual setting than in most of libm, due to various bugs here
  (primarily, always evaluating +Inf one/zero and getting unwanted
  divide-by-zero exceptions from this).  Now the actual behaviour with
  gcc -O0 is documented.  Optimization still breaks setting of exceptions
  all over libm, so nothing can depend on this working.
- tgamma(NaN)'s exception was documented as being wrong (invalid) but was
  correct (no exception with IEEEish NaNs).

Finish (?) rev.1.5.  gamma was not renamed to tgamma in one place.

Finish (?) rev.1.6.  errno.h was not completely removed.
This commit is contained in:
Bruce Evans 2007-05-02 13:49:28 +00:00
parent d06c82f169
commit dd936b27fc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=169209

View File

@ -46,11 +46,10 @@ __FBSDID("$FreeBSD$");
#include <math.h>
#include "mathimpl.h"
#include <errno.h>
/* METHOD:
* x < 0: Use reflection formula, G(x) = pi/(sin(pi*x)*x*G(x))
* At negative integers, return +Inf, and set errno.
* At negative integers, return +Inf and raise divide-by-zero.
*
* x < 6.5:
* Use argument reduction G(x+1) = xG(x) to reach the
@ -67,11 +66,15 @@ __FBSDID("$FreeBSD$");
* avoid premature round-off.
*
* Special values:
* non-positive integer: Set overflow trap; return +Inf;
* x > 171.63: Set overflow trap; return +Inf;
* NaN: Set invalid trap; return NaN
* -Inf: return +Inf (without raising any exception!);
* negative integer: return +Inf and raise divide-by-zero;
* other x ~< 177.79: return +-0 and raise underflow;
* +-0: return +-Inf and raise divide-by-zero;
* finite x ~> 171.63: return +Inf and raise divide-by-zero(!);
* +Inf: return +Inf and raise divide-by-zero(!);
* NaN: return NaN.
*
* Accuracy: Gamma(x) is accurate to within
* Accuracy: tgamma(x) is accurate to within
* x > 0: error provably < 0.9ulp.
* Maximum observed in 1,000,000 trials was .87ulp.
* x < 0: