mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* bignum.c (): refix of r33536. Don't change behavior of Bignum#/.
[ruby-core:40429] [Bug #5490] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
033244c1b2
commit
30d762795c
3 changed files with 15 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
|||
Tue Nov 22 11:26:08 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* bignum.c (): refix of r33536. Don't change behavior of Bignum#/.
|
||||
[ruby-core:40429] [Bug #5490]
|
||||
|
||||
Tue Nov 22 10:46:57 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* numeric.c (ruby_float_step): improve floating point calculations.
|
||||
|
|
9
bignum.c
9
bignum.c
|
@ -2781,14 +2781,13 @@ rb_big_divide(VALUE x, VALUE y, ID op)
|
|||
|
||||
case T_FLOAT:
|
||||
{
|
||||
double div, dy = RFLOAT_VALUE(y);
|
||||
if (dy == 0.0) rb_num_zerodiv();
|
||||
div = rb_big2dbl(x) / dy;
|
||||
if (op == '/') {
|
||||
return DBL2NUM(div);
|
||||
return DBL2NUM(rb_big2dbl(x) / RFLOAT_VALUE(y));
|
||||
}
|
||||
else {
|
||||
return rb_dbl2big(div);
|
||||
double dy = RFLOAT_VALUE(y);
|
||||
if (dy == 0.0) rb_num_zerodiv();
|
||||
return rb_dbl2big(rb_big2dbl(x) / dy);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -268,6 +268,12 @@ class TestBignum < Test::Unit::TestCase
|
|||
assert_equal(0, T32 / T64)
|
||||
end
|
||||
|
||||
def test_divide
|
||||
bug5490 = '[ruby-core:40429]'
|
||||
assert_raise(ZeroDivisionError, bug5490) {T1024./(0)}
|
||||
assert_equal(Float::INFINITY, T1024./(0.0), bug5490)
|
||||
end
|
||||
|
||||
def test_div
|
||||
assert_equal(T32.to_f, T32 / 1.0)
|
||||
assert_raise(TypeError) { T32 / "foo" }
|
||||
|
|
Loading…
Add table
Reference in a new issue