diff options
Diffstat (limited to 'rational.c')
-rw-r--r-- | rational.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/rational.c b/rational.c index 8d05342ed5..460f82cfeb 100644 --- a/rational.c +++ b/rational.c @@ -1039,6 +1039,14 @@ 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; + } + if (RB_FLOAT_TYPE_P(den)) { /* infinity due to overflow */ + num = ZERO; + den = ONE; + } return f_rational_new2(CLASS_OF(self), num, den); } } |