diff options
| author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-15 01:47:19 +0000 |
|---|---|---|
| committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-15 01:47:19 +0000 |
| commit | c0ec23d127a7a5f78b250196bae2fb891e668e96 (patch) | |
| tree | db6568d38ea896eef2e1e0a8f2431727e6d9562a | |
| parent | 21bcae094f23cb68f465c15088552ca0b8068688 (diff) | |
* bignum.c (rb_big2dbl), test/ruby/test_bignum.rb (test_to_f): A negative Bignum out of Float range should be converted to -Infinity. [ruby-core:30492] [Bug #3362]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@28324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | bignum.c | 5 | ||||
| -rw-r--r-- | test/ruby/test_bignum.rb | 6 |
3 files changed, 16 insertions, 1 deletions
@@ -1,3 +1,9 @@ +Tue Jun 15 10:29:00 2010 Kenta Murata <mrkn@mrkn.jp> + + * bignum.c (rb_big2dbl), test/ruby/test_bignum.rb (test_to_f): + A negative Bignum out of Float range should be converted to -Infinity. + [ruby-core:30492] [Bug #3362] + Mon Jun 14 18:32:38 2010 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp> * lib/drb/drb.rb: raise DRbConnError instead of ArgumentError if too @@ -1070,7 +1070,10 @@ rb_big2dbl(x) if (isinf(d)) { rb_warn("Bignum out of Float range"); - d = HUGE_VAL; + if (d < 0.0) + d = -HUGE_VAL; + else + d = HUGE_VAL; } return d; } diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb index 99c5952173..a0405ca274 100644 --- a/test/ruby/test_bignum.rb +++ b/test/ruby/test_bignum.rb @@ -103,4 +103,10 @@ class TestBignum < Test::Unit::TestCase e = assert_raise(RangeError) {(1 << big).to_s} assert_match(/too big to convert/, e.message) end + + def test_to_f + inf = 1 / 0.0 + assert_equal(inf, (1 << 65536).to_f) + assert_equal(-inf, (-1 << 65536).to_f) # [ruby-core:30492] [Bug #3362] + end end |
