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 7f3a06af80..6b248e3483 100644 --- a/rational.c +++ b/rational.c @@ -1038,6 +1038,14 @@ nurat_expt(VALUE self, VALUE other) den = ONE; break; } + 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); } } |