summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-15 09:25:13 (GMT)
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-15 09:25:13 (GMT)
commitcbe5f8820b71e0e9a214ae86e9264712e5580413 (patch)
treed4afebe00095341f51ea429f06ba294a501897f0
parent81af1bd9e8b8d84860cade1b5918b1c801b57845 (diff)
* rational.c (f_round_common): should check overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-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);