aboutsummaryrefslogtreecommitdiffstats
path: root/math.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-05 15:52:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-05 15:52:02 +0000
commitecb66b55a5f4ccc29e2c18e97f47e3b9382700b2 (patch)
treec722e827a5b10bfb55bd90efd6a379a1e843036b /math.c
parentdab8e101e3155af41e50c9e23c2a1eef243bc121 (diff)
downloadruby-ecb66b55a5f4ccc29e2c18e97f47e3b9382700b2.tar.gz
math.c: fix tgamma
* math.c (ruby_tgamma): fix tgamma(-0.0) on mingw. [ruby-core:74817] [Bug #12249] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'math.c')
-rw-r--r--math.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/math.c b/math.c
index 591d6ae2f2..e1dfe975d2 100644
--- a/math.c
+++ b/math.c
@@ -734,14 +734,20 @@ math_erfc(VALUE obj, VALUE x)
return DBL2NUM(erfc(Get_Double(x)));
}
-#ifdef __MINGW32__
+#if defined __MINGW32__
static inline double
-mingw_tgamma(const double d)
+ruby_tgamma(const double d)
{
const double g = tgamma(d);
- return (isnan(g) && !signbit(d)) ? INFINITY : g;
+ if (isinf(g)) {
+ if (d == 0.0 && signbit(d)) return -INFINITY;
+ }
+ if (isnan(g)) {
+ if (!signbit(d)) return INFINITY;
+ }
+ return g;
}
-#define tgamma(d) mingw_tgamma(d)
+#define tgamma(d) ruby_tgamma(d)
#endif
/*