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 1203cd88bd52eb..8537817e86b636 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -1221,9 +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); - if (mx<3) mx = 3; - 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); @@ -1324,7 +1325,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")); 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