summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--ext/bigdecimal/bigdecimal.c3
-rw-r--r--test/bigdecimal/test_bigdecimal.rb3
3 files changed, 13 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 91b00b0..cc06437 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Nov 22 16:49:00 2013 Kenta Murata <mrkn@mrkn.jp>
+
+ * 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@atdot.net>
* gc.c (heap_set_increment): accept minumum additional page number.
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index af1d524..88f5617 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -2381,6 +2381,9 @@ retry:
GUARD_OBJ(y, VpCreateRbObject(1, "0"));
}
VpPower(y, x, int_exp);
+ if (VpIsDef(y)) {
+ VpMidRound(y, VpGetRoundMode(), n);
+ }
return ToValue(y);
}
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 78ecd8b..8eb732a 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -1123,6 +1123,9 @@ class TestBigDecimal < Test::Unit::TestCase
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