Skip to content

Commit eaa20bd

Browse files
mrknZachary Scott
authored andcommitted
* 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] [ruby#9316] [ruby#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 5d5179b commit eaa20bd

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 <[email protected]>
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
Thu Dec 26 03:28:11 2013 Koichi Sasada <[email protected]>
212

313
* vm_insnhelper.c (argument_error): insert dummy frame to make

ext/bigdecimal/bigdecimal.c

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

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