Skip to content

Commit e7fe564

Browse files
committed
* 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
1 parent b2e85cb commit e7fe564

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Tue Jan 14 02:20:00 2014 Kenta Murata <mrkn@mrkn.jp>
2+
3+
* ext/bigdecimal/bigdecimal.c (BigDecimal_divide): Add an additional
4+
digit for the quotient to be compatible with bigdecimal 1.2.1 and
5+
the former. [ruby-core:59365] [#9316] [#9305]
6+
7+
* test/bigdecimal/test_bigdecimal.rb: tests for the above change.
8+
9+
* ext/bigdecimal/bigdecimal.gemspec: bigdecimal version 1.2.4.
10+
111
Mon Jan 13 14:55:31 2014 Zachary Scott <e@zzak.io>
212

313
* lib/xmlrpc/client.rb: [DOC] Remove note about SSL package on RAA

ext/bigdecimal/bigdecimal.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,8 +1222,10 @@ BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r)
12221222

12231223
*div = b;
12241224
mx = a->Prec + vabs(a->exponent);
1225-
if (mx<b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent);
1226-
mx =(mx + 1) * VpBaseFig();
1225+
if (mx < b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent);
1226+
mx++; /* NOTE: An additional digit is needed for the compatibility to
1227+
the version 1.2.1 and the former. */
1228+
mx = (mx + 1) * VpBaseFig();
12271229
GUARD_OBJ((*c), VpCreateRbObject(mx, "#0"));
12281230
GUARD_OBJ((*res), VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
12291231
VpDivd(*c, *res, a, b);

ext/bigdecimal/bigdecimal.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- ruby -*-
2-
_VERSION = "1.2.3"
2+
_VERSION = "1.2.4"
33
date = %w$Date:: $[1]
44

55
Gem::Specification.new do |s|

test/bigdecimal/test_bigdecimal.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,10 @@ def test_div
701701
assert_equal(BigDecimal::SIGN_NEGATIVE_ZERO, (BigDecimal.new("-0") / 1).sign)
702702
assert_equal(2, BigDecimal.new("2") / 1)
703703
assert_equal(-2, BigDecimal.new("2") / -1)
704+
705+
assert_equal(BigDecimal('1486.868686869'), BigDecimal('1472.0') / BigDecimal('0.99'), '[ruby-core:59365] [#9316]')
706+
707+
assert_equal(4.124045235, BigDecimal('0.9932') / (700 * BigDecimal('0.344045') / BigDecimal('1000.0')), '[#9305]')
704708
end
705709

706710
def test_div_with_float

0 commit comments

Comments
 (0)