summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--rational.c6
2 files changed, 10 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 23c8174..27c746c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sat Dec 15 18:24:21 2012 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * rational.c (f_round_common): should check overflow.
+
Sat Dec 15 18:00:00 2012 Tadayoshi Funaba <tadf@dotrb.org>
* ratioanl.c (float_rationalize): reduced.
diff --git a/rational.c b/rational.c
index c8d5688..afa4bd4 100644
--- a/rational.c
+++ b/rational.c
@@ -1210,6 +1210,12 @@ f_round_common(int argc, VALUE *argv, VALUE self, VALUE (*func)(VALUE))
b = f_expt10(n);
s = f_mul(self, b);
+ if (k_float_p(s)) {
+ if (f_lt_p(n, ZERO))
+ return ZERO;
+ return self;
+ }
+
s = (*func)(s);
s = f_div(f_rational_new_bang1(CLASS_OF(self), s), b);