diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-12-30 23:00:18 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-12-30 23:00:18 +0900 |
| commit | 19e539c9ee1701b34189fa0c1feb942adeb0e326 (patch) | |
| tree | cfad3ac042961b1fc0fdca1ecd6877286b11d9b5 /test/ruby | |
| parent | 966dbba8db970f13065a35d893662a981d0abae5 (diff) | |
[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.
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_numeric.rb | 4 |
1 files changed, 4 insertions, 0 deletions
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 |
