mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
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
This commit is contained in:
parent
3980985556
commit
0179055d2d
4 changed files with 19 additions and 1 deletions
|
@ -1039,6 +1039,14 @@ 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;
|
||||
}
|
||||
if (RB_FLOAT_TYPE_P(den)) { /* infinity due to overflow */
|
||||
num = ZERO;
|
||||
den = ONE;
|
||||
}
|
||||
return f_rational_new2(CLASS_OF(self), num, den);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue