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
This commit is contained in:
parent
a491508753
commit
41c533446f
@ -1,3 +1,8 @@
|
|||||||
|
Wed Apr 6 00:52:00 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* math.c (ruby_tgamma): fix tgamma(-0.0) on mingw.
|
||||||
|
[ruby-core:74817] [Bug #12249]
|
||||||
|
|
||||||
Tue Apr 5 14:50:28 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
Tue Apr 5 14:50:28 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* ext/nkf/nkf-utf8/nkf.c (mime_putc): fix typo.
|
* ext/nkf/nkf-utf8/nkf.c (mime_putc): fix typo.
|
||||||
|
14
math.c
14
math.c
@ -734,14 +734,20 @@ math_erfc(VALUE obj, VALUE x)
|
|||||||
return DBL2NUM(erfc(Get_Double(x)));
|
return DBL2NUM(erfc(Get_Double(x)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined __MINGW32__
|
||||||
static inline double
|
static inline double
|
||||||
mingw_tgamma(const double d)
|
ruby_tgamma(const double d)
|
||||||
{
|
{
|
||||||
const double g = tgamma(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
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -255,6 +255,10 @@ class TestMath < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
assert_raise(Math::DomainError) { Math.gamma(-Float::INFINITY) }
|
assert_raise(Math::DomainError) { Math.gamma(-Float::INFINITY) }
|
||||||
|
x = Math.gamma(-0.0)
|
||||||
|
mesg = "Math.gamma(-0.0) should be -INF"
|
||||||
|
assert_infinity(x, mesg)
|
||||||
|
assert_predicate(x, :negative?, mesg)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_lgamma
|
def test_lgamma
|
||||||
|
Loading…
x
Reference in New Issue
Block a user