From 06010b2b05292e6557be75f609aa1295eeea68de Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 22 Feb 2017 23:28:26 +0000 Subject: rational.c: infinity in power * rational.c (nurat_expt): return Infinity due to overflow. [ruby-core:79686] [Bug #13242]: git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- rational.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'rational.c') 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); } } -- cgit v1.2.3