diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-05 15:53:32 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-05 15:53:32 +0000 |
commit | b2b1125dcef8a982a87b53ea334d5f762d444fbc (patch) | |
tree | 13a7819ea90591e0ce8c9fbc388f94242a74fd87 /math.c | |
parent | e9fafd82f0e0906c53b216df3646f2dd91e7ddb3 (diff) | |
download | ruby-b2b1125dcef8a982a87b53ea334d5f762d444fbc.tar.gz |
math.c: fix lgamma
* math.c (ruby_lgamma_r): fix lgamma(-0.0) on mingw and OSX.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'math.c')
-rw-r--r-- | math.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -750,6 +750,22 @@ ruby_tgamma(const double d) #define tgamma(d) ruby_tgamma(d) #endif +#if defined __MINGW32__ || defined __APPLE__ +static inline double +ruby_lgamma_r(const double d, int *sign) +{ + const double g = lgamma_r(d, sign); + if (isinf(g)) { + if (d == 0.0 && signbit(d)) { + *sign = -1; + return INFINITY; + } + } + return g; +} +#define lgamma_r(d, sign) ruby_lgamma_r(d, sign) +#endif + /* * call-seq: * Math.gamma(x) -> Float |