ruby-changes:24175
From: naruse <ko1@a...>
Date: Wed, 27 Jun 2012 04:21:20 +0900 (JST)
Subject: [ruby-changes:24175] naruse:r36226 (ruby_1_9_3): merge revision(s) 35081: [Backport #6605]
naruse 2012-06-27 04:21:02 +0900 (Wed, 27 Jun 2012) New Revision: 36226 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36226 Log: merge revision(s) 35081: [Backport #6605] * bignum.c (rb_big_pow): estimate result bit size more precisely. [ruby-core:30735][Feature #3429] Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/bignum.c branches/ruby_1_9_3/test/ruby/test_bignum.rb branches/ruby_1_9_3/version.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 36225) +++ ruby_1_9_3/ChangeLog (revision 36226) @@ -1,3 +1,8 @@ +Wed Jun 27 04:20:41 2012 Nobuyoshi Nakada <nobu@r...> + + * bignum.c (rb_big_pow): estimate result bit size more precisely. + [ruby-core:30735][Feature #3429] + Tue Jun 26 20:36:53 2012 Tanaka Akira <akr@f...> * lib/drb/ssl.rb: generate 1024 bits RSA key instead of 512 bits. Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 36225) +++ ruby_1_9_3/version.h (revision 36226) @@ -1,10 +1,10 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 239 +#define RUBY_PATCHLEVEL 240 -#define RUBY_RELEASE_DATE "2012-06-26" +#define RUBY_RELEASE_DATE "2012-06-27" #define RUBY_RELEASE_YEAR 2012 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 26 +#define RUBY_RELEASE_DAY 27 #include "ruby/version.h" Index: ruby_1_9_3/bignum.c =================================================================== --- ruby_1_9_3/bignum.c (revision 36225) +++ ruby_1_9_3/bignum.c (revision 36226) @@ -3079,10 +3079,11 @@ else { VALUE z = 0; SIGNED_VALUE mask; - const long BIGLEN_LIMIT = 1024*1024 / SIZEOF_BDIGITS; + const long xlen = RBIGNUM_LEN(x) - 1; + const long xbits = ffs(RBIGNUM_DIGITS(x)[xlen]) + SIZEOF_BDIGITS*BITSPERDIG*xlen; + const long BIGLEN_LIMIT = BITSPERDIG*1024*1024; - if ((RBIGNUM_LEN(x) > BIGLEN_LIMIT) || - (RBIGNUM_LEN(x) > BIGLEN_LIMIT / yy)) { + if ((xbits > BIGLEN_LIMIT) || (xbits * yy > BIGLEN_LIMIT)) { rb_warn("in a**b, b may be too big"); d = (double)yy; break; Index: ruby_1_9_3/test/ruby/test_bignum.rb =================================================================== --- ruby_1_9_3/test/ruby/test_bignum.rb (revision 36225) +++ ruby_1_9_3/test/ruby/test_bignum.rb (revision 36226) @@ -299,6 +299,9 @@ ### rational changes the behavior of Bignum#** #assert_raise(TypeError) { T32**"foo" } assert_raise(TypeError, ArgumentError) { T32**"foo" } + + feature3429 = '[ruby-core:30735]' + assert_instance_of(Bignum, (2 ** 7830457), feature3429) end def test_and -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/