aboutsummaryrefslogtreecommitdiffstats
path: root/rational.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-22 23:49:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-22 23:49:40 +0000
commitc053c35ecd4a83ff2b89270f06d7620d93b2c8f8 (patch)
tree3cb083d98bb165b0c650fff58d4573408f917286 /rational.c
parentc6da8470b9f1f317825e55e28ed1ec1201a7ecf7 (diff)
downloadruby-c053c35ecd4a83ff2b89270f06d7620d93b2c8f8.tar.gz
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/trunk@57689 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 e779505fd0..4bdc695dc1 100644
--- a/rational.c
+++ b/rational.c
@@ -1046,6 +1046,10 @@ nurat_expt(VALUE self, VALUE other)
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);
}
}