summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-10 04:53:46 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-10 04:53:46 (GMT)
commit3f6fb5f72ad2a4a911518ab47e260089e9e4089a (patch)
tree0815f7950cdfdb2c335c4f50a34bf503ac1d9307 /math.c
parentc5c5e96643fd674cc44bf6c4f6edd965aa317c9e (diff)
math.c: fix tgamma on mingw
* math.c (mingw_tgamma): tgamma(3) on mingw returns a NaN for a big number, not infinity. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'math.c')
-rw-r--r--math.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/math.c b/math.c
index 0ce948f..f66f9ff 100644
--- a/math.c
+++ b/math.c
@@ -786,6 +786,16 @@ math_erfc(VALUE obj, VALUE x)
return DBL2NUM(erfc(Get_Double(x)));
}
+#ifdef __MINGW32__
+static inline double
+mingw_tgamma(const double d)
+{
+ const double g = tgamma(d);
+ return (isnan(g) && !signbit(d)) ? INFINITY : g;
+}
+#define tgamma(d) mingw_tgamma(d)
+#endif
+
/*
* call-seq:
* Math.gamma(x) -> Float