From a1d9fbef05fbf507b4c68cf3fbc50c6e27a3293e Mon Sep 17 00:00:00 2001 From: Kenta Murata Date: Fri, 24 Dec 2021 00:26:34 +0900 Subject: [ruby/bigdecimal] Fix the result precision of BigDecimal#divmod https://github.com/ruby/bigdecimal/commit/a32f6cb9e2 --- test/bigdecimal/test_bigdecimal.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index bbfcbec4df..825d7ec93f 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -1047,11 +1047,13 @@ class TestBigDecimal < Test::Unit::TestCase a = BigDecimal('2e55') b = BigDecimal('1.23456789e10') q, r = a.divmod(b) - assert_equal((a/b), q) + assert_equal((a/b).round(0, :down), q) + assert_equal((a - q*b), r) b = BigDecimal('-1.23456789e10') q, r = a.divmod(b) - assert_equal((a/b), q) + assert_equal((a/b).round(0, :down) - 1, q) + assert_equal((a - q*b), r) end def test_divmod_error -- cgit v1.2.3