diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-25 18:16:16 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-25 18:16:16 +0000 |
commit | f84d286415328e4dfd64968d146d916ce60791aa (patch) | |
tree | 78ab593b57f2915c707d77f19e5f3f948e88a1c6 /rational.c | |
parent | d41018464386c1ce686a65af03fb711a9af1baa1 (diff) |
merge revision(s) 57688,57689: [Backport #13242]
rational.c: infinity in power
* rational.c (nurat_expt): return Infinity due to overflow.
[ruby-core:79686] [Bug #13242]:
rational.c: infinity in power
* rational.c (nurat_expt): return 0 due to overflow.
[ruby-core:79686] [Bug #13242]:
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'rational.c')
-rw-r--r-- | rational.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/rational.c b/rational.c index 3e5dea3349..97d9b35a16 100644 --- a/rational.c +++ b/rational.c @@ -1043,6 +1043,10 @@ 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; + } return f_rational_new2(CLASS_OF(self), num, den); } } |