summaryrefslogtreecommitdiffstats
path: root/missing
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-09 02:10:57 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-09 02:10:57 +0000
commit35caa730ab8946a5f59cd603b6d3315f12530424 (patch)
tree6d011718fa140d5f792091c4142b0e304a02a3c3 /missing
parentab2128729fd387e44d6c791a6132abdad2c25a76 (diff)
downloadruby-35caa730ab8946a5f59cd603b6d3315f12530424.tar.gz
ruby-35caa730ab8946a5f59cd603b6d3315f12530424.tar.xz
ruby-35caa730ab8946a5f59cd603b6d3315f12530424.zip
* missing/xlgamma_r.c (lgamma_r): return HUGE_VAL for non-positive
integers. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'missing')
-rw-r--r--missing/lgamma_r.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/missing/lgamma_r.c b/missing/lgamma_r.c
index d4402c67b..ab6c28294 100644
--- a/missing/lgamma_r.c
+++ b/missing/lgamma_r.c
@@ -12,6 +12,7 @@ reference - Haruhiko Okumura: C-gengo niyoru saishin algorithm jiten
gamma.c -- Gamma function
***********************************************************/
#include <math.h>
+#include <errno.h>
#define PI 3.14159265358979324 /* $\pi$ */
#define LOG_2PI 1.83787706640934548 /* $\log 2\pi$ */
#define LOG_PI 1.14472988584940017 /* $\log_e \pi$ */
@@ -47,13 +48,13 @@ loggamma(double x) /* the natural logarithm of the Gamma function. */
double
lgamma_r(double x, int *signp)
{
- if (x < 0) {
+ if (x <= 0) {
double i, f, s;
f = modf(-x, &i);
- if (f == 0.0) {
- static const double zero = 0.0;
+ if (f == 0.0) { /* pole error */
*signp = 1;
- return 1.0/zero;
+ errno = ERANGE;
+ return HUGE_VAL;
}
*signp = (fmod(i, 2.0) != 0.0) ? 1 : -1;
s = sin(PI * f);