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
This commit is contained in:
parent
06010b2b05
commit
2e2063fe16
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -959,6 +959,8 @@ class Rational_Test < Test::Unit::TestCase
|
||||
bug = '[ruby-core:79686] [Bug #13242]: Infinity due to overflow'
|
||||
x = EnvUtil.suppress_warning {4r**40000000}
|
||||
assert_predicate x, :infinite?, bug
|
||||
x = EnvUtil.suppress_warning {(1/4r)**40000000}
|
||||
assert_equal 0, x, bug
|
||||
end
|
||||
|
||||
def test_positive_p
|
||||
|
Loading…
x
Reference in New Issue
Block a user