зеркало из https://github.com/github/ruby.git
* bignum.c (rb_big_pow): estimate result bit size more precisely.
[ruby-core:30735][Feature #3429] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
2555f3f5bf
Коммит
ed4c5f38ba
|
@ -1,3 +1,8 @@
|
|||
Sun Mar 18 17:17:48 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* bignum.c (rb_big_pow): estimate result bit size more precisely.
|
||||
[ruby-core:30735][Feature #3429]
|
||||
|
||||
Sun Mar 18 17:17:36 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* gc.c (free_method_entry_i): method entry may be in
|
||||
|
|
7
bignum.c
7
bignum.c
|
@ -3095,10 +3095,11 @@ rb_big_pow(VALUE x, VALUE y)
|
|||
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;
|
||||
|
|
|
@ -326,6 +326,9 @@ class TestBignum < Test::Unit::TestCase
|
|||
### 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
|
||||
|
|
Загрузка…
Ссылка в новой задаче