From 5d5179b619829b32a89c314090737716c14b6468 Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Tue, 14 Jan 2014 00:54:17 -0800 Subject: [PATCH 1/2] Revert "temp workaround BigDecimal division issue [Bug #9316]" This reverts commit 1e778b3b207394d2dcbe9570d4434fcf41345acf. Please see ruby/ruby@e7fe564 for the official patch --- ext/bigdecimal/bigdecimal.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 1203cd88bd52eb..e0b7c01e0853d6 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -1222,7 +1222,6 @@ BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r) *div = b; mx = a->Prec + vabs(a->exponent); if (mxPrec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent); - if (mx<3) mx = 3; mx =(mx + 1) * VpBaseFig(); GUARD_OBJ((*c), VpCreateRbObject(mx, "#0")); GUARD_OBJ((*res), VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0")); @@ -1324,7 +1323,6 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod) mx = a->Prec + vabs(a->exponent); if (mxPrec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent); - if (mx<3) mx = 3; mx = (mx + 1) * VpBaseFig(); GUARD_OBJ(c, VpCreateRbObject(mx, "0")); GUARD_OBJ(res, VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0")); From eaa20bd3c29e0876d6aac7fe30764a920bdac3cf Mon Sep 17 00:00:00 2001 From: mrkn Date: Mon, 13 Jan 2014 17:29:58 +0000 Subject: [PATCH 2/2] * 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 --- ChangeLog | 10 ++++++++++ ext/bigdecimal/bigdecimal.c | 6 ++++-- ext/bigdecimal/bigdecimal.gemspec | 2 +- test/bigdecimal/test_bigdecimal.rb | 4 ++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb0c6ac930045c..967980eaa9d5a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Tue Jan 14 02:20:00 2014 Kenta Murata + + * 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. + Thu Dec 26 03:28:11 2013 Koichi Sasada * vm_insnhelper.c (argument_error): insert dummy frame to make diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index e0b7c01e0853d6..8537817e86b636 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -1221,8 +1221,10 @@ BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r) *div = b; mx = a->Prec + vabs(a->exponent); - if (mxPrec + 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 676e05bacbff48..7be9d7275bd2fa 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 6fdc422fdf61e3..02bb5a51755924 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -701,6 +701,10 @@ def test_div 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 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy