diff --git a/ChangeLog b/ChangeLog index 23c8174af2..27c746c766 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Dec 15 18:24:21 2012 Tadayoshi Funaba + + * rational.c (f_round_common): should check overflow. + Sat Dec 15 18:00:00 2012 Tadayoshi Funaba * ratioanl.c (float_rationalize): reduced. diff --git a/rational.c b/rational.c index c8d5688c94..afa4bd4cec 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);