summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authortakano32 <takano32@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-18 03:06:32 +0000
committertakano32 <takano32@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-18 03:06:32 +0000
commita1c4d60560e76e49a5825d35a40b8a6c32438afa (patch)
tree725e9ca07bf7870bfe5b9086836aa67b9b439575 /math.c
parent6c2373ea6758040ecc2607395adad03f98d01308 (diff)
* math.c (math_gamma): fix incorrect comparison expression.
see also [ruby-dev:39709] [Bug #2381] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'math.c')
-rw-r--r--math.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/math.c b/math.c
index 2b877ec..1a448b8 100644
--- a/math.c
+++ b/math.c
@@ -666,14 +666,13 @@ math_gamma(VALUE obj, VALUE x)
};
double d0, d;
double intpart, fracpart;
- int n;
Need_Float(x);
d0 = RFLOAT_VALUE(x);
fracpart = modf(d0, &intpart);
if (fracpart == 0.0 &&
- 0 < intpart &&
- (n = (int)intpart - 1) < numberof(fact_table)) {
- return DBL2NUM(fact_table[n]);
+ 0 < intpart &&
+ intpart - 1 < (double)numberof(fact_table)) {
+ return DBL2NUM(fact_table[(int)intpart - 1]);
}
errno = 0;
d = tgamma(d0);