From 19e539c9ee1701b34189fa0c1feb942adeb0e326 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 30 Dec 2025 23:00:18 +0900 Subject: [Bug #21814] Fix negative bignum modulo If modulo is zero, do not apply bias even if the divisor is zero. `BIGNUM_POSITIVE_P` is true even on bignum zero. --- test/ruby/test_numeric.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb index 3bf93ef20d..35496ac875 100644 --- a/test/ruby/test_numeric.rb +++ b/test/ruby/test_numeric.rb @@ -489,6 +489,10 @@ class TestNumeric < Test::Unit::TestCase assert_equal(0, 0.pow(3, 1)) assert_equal(0, 2.pow(3, 1)) assert_equal(0, -2.pow(3, 1)) + + min, max = RbConfig::LIMITS.values_at("FIXNUM_MIN", "FIXNUM_MAX") + assert_equal(0, 0.pow(2, min)) + assert_equal(0, Integer.sqrt(max+1).pow(2, min)) end end -- cgit v1.2.3