From 1acfb03370704aee624b7a1e5ccf4776f40f2895 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Wed, 6 Jun 2012 05:47:45 +0000 Subject: merge revision(s) 28324: * 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_7@35941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 15 ++++++--------- bignum.c | 5 ++++- test/ruby/test_bignum.rb | 6 ++++++ version.h | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index dd5808aa77..69c7cedb50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Jun 6 14:44:13 2012 Kenta Murata + + * 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] + Wed Jun 6 14:06:02 2012 Tanaka Akira * lib/webrick/utils.rb: fix fcntl call. @@ -21,15 +27,6 @@ Sat Apr 14 18:51:41 2012 Nobuyoshi Nakada GC. [exerb-dev:0578]. patched by MURASE Masamitsu at [exerb-dev:0580] -Tue Mar 6 12:05:42 2012 Nobuyoshi Nakada - - * lib/yaml/rubytypes.rb (Exception.yaml_new): fix bug that causes - YAML serialization problem for Exception. - Exception#initialize doesn't use visible instance variable for - the exception message, so call the method with the message. - patched by Jingwen Owen Ou . - http://github.com/ruby/ruby/pull/41 - Fri Mar 2 11:44:33 2012 Nobuyoshi Nakada * marshal.c (mark_dump_arg): mark destination string. patch by diff --git a/bignum.c b/bignum.c index 77697ae4fa..6c0bf651da 100644 --- a/bignum.c +++ b/bignum.c @@ -1069,7 +1069,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 diff --git a/version.h b/version.h index 3b58c4e3c8..3d64d07564 100644 --- a/version.h +++ b/version.h @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2012-06-06" #define RUBY_VERSION_CODE 187 #define RUBY_RELEASE_CODE 20120606 -#define RUBY_PATCHLEVEL 364 +#define RUBY_PATCHLEVEL 365 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 -- cgit v1.2.3