aboutsummaryrefslogtreecommitdiffstats
path: root/rational.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-22 23:28:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-22 23:28:26 +0000
commitc6da8470b9f1f317825e55e28ed1ec1201a7ecf7 (patch)
treee76c939853253e4f2dbba1b9e12193d56a1ca6d2 /rational.c
parent609e35cd2f45b9113c1da3deb43e177ae1272ab9 (diff)
downloadruby-c6da8470b9f1f317825e55e28ed1ec1201a7ecf7.tar.gz
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
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);
}
}