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
This commit is contained in:
parent
8c4c3508d9
commit
542d3a071f
@ -1,4 +1,6 @@
|
|||||||
Wed Apr 6 00:52:00 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Apr 6 00:53:31 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* math.c (ruby_lgamma_r): fix lgamma(-0.0) on mingw and OSX.
|
||||||
|
|
||||||
* math.c (ruby_tgamma): fix tgamma(-0.0) on mingw.
|
* math.c (ruby_tgamma): fix tgamma(-0.0) on mingw.
|
||||||
[ruby-core:74817] [Bug #12249]
|
[ruby-core:74817] [Bug #12249]
|
||||||
|
16
math.c
16
math.c
@ -750,6 +750,22 @@ ruby_tgamma(const double d)
|
|||||||
#define tgamma(d) ruby_tgamma(d)
|
#define tgamma(d) ruby_tgamma(d)
|
||||||
#endif
|
#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:
|
* call-seq:
|
||||||
* Math.gamma(x) -> Float
|
* Math.gamma(x) -> Float
|
||||||
|
@ -275,6 +275,11 @@ class TestMath < Test::Unit::TestCase
|
|||||||
assert_float_and_int([Math.log(6), 1], Math.lgamma(4))
|
assert_float_and_int([Math.log(6), 1], Math.lgamma(4))
|
||||||
|
|
||||||
assert_raise(Math::DomainError) { Math.lgamma(-Float::INFINITY) }
|
assert_raise(Math::DomainError) { Math.lgamma(-Float::INFINITY) }
|
||||||
|
x, sign = Math.lgamma(-0.0)
|
||||||
|
mesg = "Math.lgamma(-0.0) should be [INF, -1]"
|
||||||
|
assert_infinity(x, mesg)
|
||||||
|
assert_predicate(x, :positive?, mesg)
|
||||||
|
assert_equal(-1, sign, mesg)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fixnum_to_f
|
def test_fixnum_to_f
|
||||||
|
Loading…
x
Reference in New Issue
Block a user