ruby-changes:31717
From: mrkn <ko1@a...>
Date: Fri, 22 Nov 2013 16:52:26 +0900 (JST)
Subject: [ruby-changes:31717] mrkn:r43796 (trunk): * ext/bigdecimal/bigdecimal.c (BigDecimal_power): Round the result value.
mrkn 2013-11-22 16:52:17 +0900 (Fri, 22 Nov 2013) New Revision: 43796 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43796 Log: * ext/bigdecimal/bigdecimal.c (BigDecimal_power): Round the result value. [Bug #8818] [ruby-core:56802] * test/bigdecimal/test_bigdecimal.rb: Add a test for the above fix. Modified files: trunk/ChangeLog trunk/ext/bigdecimal/bigdecimal.c trunk/test/bigdecimal/test_bigdecimal.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 43795) +++ ChangeLog (revision 43796) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Nov 22 16:49:00 2013 Kenta Murata <mrkn@m...> + + * ext/bigdecimal/bigdecimal.c (BigDecimal_power): Round the result value. + [Bug #8818] [ruby-core:56802] + + * test/bigdecimal/test_bigdecimal.rb: Add a test for the above fix. + Fri Nov 22 16:25:43 2013 Koichi Sasada <ko1@a...> * gc.c (heap_set_increment): accept minumum additional page number. Index: ext/bigdecimal/bigdecimal.c =================================================================== --- ext/bigdecimal/bigdecimal.c (revision 43795) +++ ext/bigdecimal/bigdecimal.c (revision 43796) @@ -2381,6 +2381,9 @@ retry: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2381 GUARD_OBJ(y, VpCreateRbObject(1, "0")); } VpPower(y, x, int_exp); + if (VpIsDef(y)) { + VpMidRound(y, VpGetRoundMode(), n); + } return ToValue(y); } Index: test/bigdecimal/test_bigdecimal.rb =================================================================== --- test/bigdecimal/test_bigdecimal.rb (revision 43795) +++ test/bigdecimal/test_bigdecimal.rb (revision 43796) @@ -1123,6 +1123,9 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L1123 e = BigDecimal("2.71828182845904523536028747135266249775724709369996") pow = BigDecimal("22.459157718361045473") assert_equal(pow, pi.power(e, 20)) + + b = BigDecimal('1.034482758620689655172413793103448275862068965517241379310344827586206896551724') + assert_equal(BigDecimal('0.114523E1'), b.power(4, 5), '[Bug #8818] [ruby-core:56802]') end def test_limit -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/