зеркало из https://github.com/github/ruby.git
* math.c (math_gamma): add error check.
(math_lgamma): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
1c6e4ff1a0
Коммит
c8aa30a958
|
@ -1,3 +1,8 @@
|
|||
Sat Feb 9 11:47:03 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* math.c (math_gamma): add error check.
|
||||
(math_lgamma): ditto.
|
||||
|
||||
Sat Feb 9 11:09:26 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* missing/lgamma_r.c (lgamma_r): return HUGE_VAL for non-positive
|
||||
|
|
12
math.c
12
math.c
|
@ -530,8 +530,12 @@ math_erfc(VALUE obj, VALUE x)
|
|||
static VALUE
|
||||
math_gamma(VALUE obj, VALUE x)
|
||||
{
|
||||
double d;
|
||||
Need_Float(x);
|
||||
return DOUBLE2NUM(tgamma(RFLOAT_VALUE(x)));
|
||||
errno = 0;
|
||||
d = tgamma(RFLOAT_VALUE(x));
|
||||
domain_check(d, "gamma");
|
||||
return DOUBLE2NUM(d);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -549,10 +553,14 @@ math_gamma(VALUE obj, VALUE x)
|
|||
static VALUE
|
||||
math_lgamma(VALUE obj, VALUE x)
|
||||
{
|
||||
double d;
|
||||
int sign;
|
||||
VALUE v;
|
||||
Need_Float(x);
|
||||
v = DOUBLE2NUM(lgamma_r(RFLOAT_VALUE(x), &sign));
|
||||
errno = 0;
|
||||
d = lgamma_r(RFLOAT_VALUE(x), &sign);
|
||||
domain_check(d, "lgamma");
|
||||
v = DOUBLE2NUM(d);
|
||||
return rb_assoc_new(v, INT2FIX(sign));
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче