summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-12 14:18:02 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-12 14:18:02 +0000
commit0179055d2d146d495b93c148e431cf103b55208f (patch)
tree8823f2dafecd4990a45b9979ac4202d4c94c7dc4 /numeric.c
parent398098555620384bc2796dbb3f977a81f640af39 (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_4@57911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/numeric.c b/numeric.c
index 28ad30d764..f67b910c1f 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3904,6 +3904,8 @@ int_pow(long x, unsigned long y)
VALUE v;
bignum:
v = rb_big_pow(rb_int2big(x), LONG2NUM(y));
+ if (RB_FLOAT_TYPE_P(v)) /* infinity due to overflow */
+ return v;
if (z != 1) v = rb_big_mul(rb_int2big(neg ? -z : z), v);
return v;
}