aboutsummaryrefslogtreecommitdiffstats
path: root/rational.c
diff options
context:
space:
mode:
Diffstat (limited to 'rational.c')
-rw-r--r--rational.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/rational.c b/rational.c
index d88f50f886..64fc10ce47 100644
--- a/rational.c
+++ b/rational.c
@@ -1991,6 +1991,15 @@ rb_numeric_quo(VALUE x, VALUE y)
return nurat_div(x, y);
}
+VALUE
+rb_rational_canonicalize(VALUE x)
+{
+ if (RB_TYPE_P(x, T_RATIONAL)) {
+ get_dat1(x);
+ if (f_one_p(dat->den)) return dat->num;
+ }
+ return x;
+}
/*
* call-seq: