1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) 44588: [Backport #9316]

* 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/branches/ruby_2_1@44711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2014-01-27 07:56:58 +00:00
parent 2b4becd6bc
commit 16c8a6d4b4
5 changed files with 20 additions and 4 deletions

View file

@ -1,3 +1,13 @@
Mon Jan 27 16:49:52 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 27 16:45:34 2014 Yamashita Yuu <yamashita@geishatokyo.com>
* ext/openssl/ossl_ssl.c (Init_ossl_ssl): Declare a constant

View file

@ -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 (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);

View file

@ -1,5 +1,5 @@
# -*- ruby -*-
_VERSION = "1.2.3"
_VERSION = "1.2.4"
date = %w$Date:: $[1]
Gem::Specification.new do |s|

View file

@ -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

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.1"
#define RUBY_RELEASE_DATE "2014-01-27"
#define RUBY_PATCHLEVEL 9
#define RUBY_PATCHLEVEL 10
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 1