diff options
author | bde <bde@FreeBSD.org> | 2007-05-02 13:49:28 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 2007-05-02 13:49:28 +0000 |
commit | 98484906b64f28e7d3ec42156666cd1efd6b9998 (patch) | |
tree | d6b502946bdf8aa6d632cb846ca1dea78f61087a /lib/msun | |
parent | 803b9be8be0827d6f2fde839f6dcd9225a2609be (diff) | |
download | FreeBSD-src-98484906b64f28e7d3ec42156666cd1efd6b9998.zip FreeBSD-src-98484906b64f28e7d3ec42156666cd1efd6b9998.tar.gz |
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.
Diffstat (limited to 'lib/msun')
-rw-r--r-- | lib/msun/bsdsrc/b_tgamma.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/msun/bsdsrc/b_tgamma.c b/lib/msun/bsdsrc/b_tgamma.c index a8e5755..784e563 100644 --- a/lib/msun/bsdsrc/b_tgamma.c +++ b/lib/msun/bsdsrc/b_tgamma.c @@ -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: |