mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 20:19:19 +00:00
Fix wrong condition in base multiplying loop.
This commit is contained in:
parent
c5937c1bca
commit
f4f728b319
Notes:
git
2025-11-12 04:59:06 +00:00
Merged-By: tompng <tomoyapenguin@gmail.com>
@ -5553,7 +5553,7 @@ rb_int_digits_bigbase(VALUE num, VALUE base)
|
||||
}
|
||||
|
||||
bases = rb_ary_new();
|
||||
for (VALUE b = base; int_lt(b, num) == Qtrue; b = rb_int_mul(b, b)) {
|
||||
for (VALUE b = base; int_le(b, num) == Qtrue; b = rb_int_mul(b, b)) {
|
||||
rb_ary_push(bases, b);
|
||||
}
|
||||
digits = rb_ary_new_from_args(1, num);
|
||||
|
||||
@ -821,6 +821,9 @@ class TestBignum < Test::Unit::TestCase
|
||||
assert_equal([7215, 2413, 6242], T1024P.digits(10_000).first(3))
|
||||
assert_equal([11], 11.digits(T1024P))
|
||||
assert_equal([T1024P - 1, 1], (T1024P + T1024P - 1).digits(T1024P))
|
||||
bug21680 = '[ruby-core:123769] [Bug #21680]'
|
||||
assert_equal([0] * 64 + [1], (2**512).digits(256), bug21680)
|
||||
assert_equal([0] * 128 + [1], (123**128).digits(123), bug21680)
|
||||
end
|
||||
|
||||
def test_digits_for_negative_numbers
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user