* math.c (math_gamma): rename NGAMMA_TABLE to NFACT_TABLE.
specify the size of the fact_table. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
09d9d913c0
commit
717bc13d29
6
math.c
6
math.c
@ -836,12 +836,12 @@ mingw_tgamma(const double d)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NGAMMA_TABLE 23
|
#define NFACT_TABLE 23
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
math_gamma(VALUE obj, VALUE x)
|
math_gamma(VALUE obj, VALUE x)
|
||||||
{
|
{
|
||||||
static const double fact_table[] = {
|
static const double fact_table[NFACT_TABLE] = {
|
||||||
/* fact(0) */ 1.0,
|
/* fact(0) */ 1.0,
|
||||||
/* fact(1) */ 1.0,
|
/* fact(1) */ 1.0,
|
||||||
/* fact(2) */ 2.0,
|
/* fact(2) */ 2.0,
|
||||||
@ -875,7 +875,7 @@ math_gamma(VALUE obj, VALUE x)
|
|||||||
if (isinf(d) && signbit(d)) domain_error("gamma");
|
if (isinf(d) && signbit(d)) domain_error("gamma");
|
||||||
if (d == floor(d)) {
|
if (d == floor(d)) {
|
||||||
if (d < 0.0) domain_error("gamma");
|
if (d < 0.0) domain_error("gamma");
|
||||||
if (1.0 <= d && d <= (double)NGAMMA_TABLE) {
|
if (1.0 <= d && d <= (double)NFACT_TABLE) {
|
||||||
return DBL2NUM(fact_table[(int)d - 1]);
|
return DBL2NUM(fact_table[(int)d - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user