summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--math.c7
2 files changed, 8 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 623ba10..d3c34ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Nov 18 11:57:32 2009 TAKANO Mitsuhiro (takano32) <tak@no32.tk>
+
+ * math.c (math_gamma): fix incorrect comparison expression.
+ see also [ruby-dev:39709] [Bug #2381]
+
Wed Nov 18 11:37:05 2009 NARUSE, Yui <naruse@ruby-lang.org>
* io.c (rb_scan_open_args): move path encoding conversion
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);