aboutsummaryrefslogtreecommitdiffstats
path: root/rational.c
diff options
context:
space:
mode:
Diffstat (limited to 'rational.c')
-rw-r--r--rational.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/rational.c b/rational.c
index 13c44f7925..e779505fd0 100644
--- a/rational.c
+++ b/rational.c
@@ -1042,6 +1042,10 @@ nurat_expt(VALUE self, VALUE other)
num = ONE;
den = ONE;
}
+ if (RB_FLOAT_TYPE_P(num)) { /* infinity due to overflow */
+ if (RB_FLOAT_TYPE_P(den)) return DBL2NUM(NAN);
+ return num;
+ }
return f_rational_new2(CLASS_OF(self), num, den);
}
}