summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-13 17:29:58 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-13 17:29:58 +0000
commite7fe5648cf10528422ce720b50c8641bd5d8c267 (patch)
treed3d804081658d6ba737cb15b0711f26e9bccd8ce
parentb2e85cbdf4980e840ffda2cdfc9c18f45e636ecb (diff)
* ext/bigdecimal/bigdecimal.c (BigDecimal_divide): Add an additional
digit for the quotient to be compatible with bigdecimal 1.2.1 and the former. [ruby-core:59365] [#9316] [#9305] * test/bigdecimal/test_bigdecimal.rb: tests for the above change. * ext/bigdecimal/bigdecimal.gemspec: bigdecimal version 1.2.4. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--ext/bigdecimal/bigdecimal.c6
-rw-r--r--ext/bigdecimal/bigdecimal.gemspec2
-rw-r--r--test/bigdecimal/test_bigdecimal.rb4
4 files changed, 19 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index e206b11..8d0b39f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Tue Jan 14 02:20:00 2014 Kenta Murata <mrkn@mrkn.jp>
+
+ * ext/bigdecimal/bigdecimal.c (BigDecimal_divide): Add an additional
+ digit for the quotient to be compatible with bigdecimal 1.2.1 and
+ the former. [ruby-core:59365] [#9316] [#9305]
+
+ * test/bigdecimal/test_bigdecimal.rb: tests for the above change.
+
+ * ext/bigdecimal/bigdecimal.gemspec: bigdecimal version 1.2.4.
+
Mon Jan 13 14:55:31 2014 Zachary Scott <e@zzak.io>
* lib/xmlrpc/client.rb: [DOC] Remove note about SSL package on RAA
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 5af8441..c7d9945 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -1222,8 +1222,10 @@ BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r)
*div = b;
mx = a->Prec + vabs(a->exponent);
- if (mx<b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent);
- mx =(mx + 1) * VpBaseFig();
+ if (mx < b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent);
+ mx++; /* NOTE: An additional digit is needed for the compatibility to
+ the version 1.2.1 and the former. */
+ mx = (mx + 1) * VpBaseFig();
GUARD_OBJ((*c), VpCreateRbObject(mx, "#0"));
GUARD_OBJ((*res), VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
VpDivd(*c, *res, a, b);
diff --git a/ext/bigdecimal/bigdecimal.gemspec b/ext/bigdecimal/bigdecimal.gemspec
index 676e05b..7be9d72 100644
--- a/ext/bigdecimal/bigdecimal.gemspec
+++ b/ext/bigdecimal/bigdecimal.gemspec
@@ -1,5 +1,5 @@
# -*- ruby -*-
-_VERSION = "1.2.3"
+_VERSION = "1.2.4"
date = %w$Date:: $[1]
Gem::Specification.new do |s|
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 6fdc422..02bb5a5 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -701,6 +701,10 @@ class TestBigDecimal < Test::Unit::TestCase
assert_equal(BigDecimal::SIGN_NEGATIVE_ZERO, (BigDecimal.new("-0") / 1).sign)
assert_equal(2, BigDecimal.new("2") / 1)
assert_equal(-2, BigDecimal.new("2") / -1)
+
+ assert_equal(BigDecimal('1486.868686869'), BigDecimal('1472.0') / BigDecimal('0.99'), '[ruby-core:59365] [#9316]')
+
+ assert_equal(4.124045235, BigDecimal('0.9932') / (700 * BigDecimal('0.344045') / BigDecimal('1000.0')), '[#9305]')
end
def test_div_with_float