summaryrefslogtreecommitdiff
path: root/rational.c
diff options
context:
space:
mode:
Diffstat (limited to 'rational.c')
-rw-r--r--rational.c6
1 files changed, 6 insertions, 0 deletions
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);