From a5b4b806de3b130348a92aa3306fbb9318efb762 Mon Sep 17 00:00:00 2001 From: Kenta Murata Date: Wed, 13 Jan 2021 10:28:23 +0900 Subject: [ruby/bigdecimal] Allow digits=0 in BigDecimal(flt) and Float#to_d Using dtoa of mode=0, we can determine the number of digits in decimal that is necessary to represent the given Float number without errors. This change permits digits=0 in BigDecimal(flt) and Float#to_d, and these methods use dtoa of mode=0 when the given digits is 0. Internal implicit conversion from Float also uses digits=0. [Fix GH-70] https://github.com/ruby/bigdecimal/commit/2dbe170e35 --- test/bigdecimal/test_bigdecimal.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/bigdecimal/test_bigdecimal.rb') diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index e8fd85a526..0063fb9743 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -917,6 +917,7 @@ class TestBigDecimal < Test::Unit::TestCase def test_mult_with_float assert_kind_of(BigDecimal, BigDecimal("3") * 1.5) + assert_equal(BigDecimal("64.4"), BigDecimal(1) * 64.4) end def test_mult_with_rational @@ -955,6 +956,7 @@ class TestBigDecimal < Test::Unit::TestCase def test_div_with_float assert_kind_of(BigDecimal, BigDecimal("3") / 1.5) + assert_equal(BigDecimal("0.5"), BigDecimal(1) / 2.0) end def test_div_with_rational -- cgit v1.2.1