ruby-changes:16348
From: mrkn <ko1@a...>
Date: Tue, 15 Jun 2010 10:48:06 +0900 (JST)
Subject: [ruby-changes:16348] Ruby:r28324 (ruby_1_8): * bignum.c (rb_big2dbl), test/ruby/test_bignum.rb (test_to_f): A negative Bignum out of Float range should be converted to -Infinity. [Bug #3362]
mrkn 2010-06-15 10:47:19 +0900 (Tue, 15 Jun 2010) New Revision: 28324 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28324 Log: * 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] Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/bignum.c branches/ruby_1_8/test/ruby/test_bignum.rb Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 28323) +++ ruby_1_8/ChangeLog (revision 28324) @@ -1,3 +1,9 @@ +Tue Jun 15 10:29:00 2010 Kenta Murata <mrkn@m...> + + * 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@m...> * lib/drb/drb.rb: raise DRbConnError instead of ArgumentError if too Index: ruby_1_8/bignum.c =================================================================== --- ruby_1_8/bignum.c (revision 28323) +++ ruby_1_8/bignum.c (revision 28324) @@ -1070,7 +1070,10 @@ 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; } Index: ruby_1_8/test/ruby/test_bignum.rb =================================================================== --- ruby_1_8/test/ruby/test_bignum.rb (revision 28323) +++ ruby_1_8/test/ruby/test_bignum.rb (revision 28324) @@ -103,4 +103,10 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/