From 99f8f14d89308c17d8e9e53e03dd5ead6984e7fc Mon Sep 17 00:00:00 2001 From: mrkn Date: Sun, 10 Jul 2011 14:05:07 +0000 Subject: * ext/bigdecimal/bigdecimal.c (rmpd_power_by_big_decimal): fix precision treatment errors. * test/bigdecimal/test_bigdecimal.rb: add tests for the above change. fix precision treatment errors. * ext/bigdecimal/bigdecimal.c (BigDecimal_power): precision argument should be optional for its compatibility. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/bigdecimal/test_bigdecimal.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/bigdecimal') diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index 9bd068bfe5..96211a09c7 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -964,6 +964,20 @@ class TestBigDecimal < Test::Unit::TestCase end end + def test_power_without_prec + pi = BigDecimal("3.14159265358979323846264338327950288419716939937511") + e = BigDecimal("2.71828182845904523536028747135266249775724709369996") + pow = BigDecimal("22.4591577183610454734271522045437350275893151339967843873233068") + assert_equal(pow, pi.power(e)) + end + + def test_power_with_prec + pi = BigDecimal("3.14159265358979323846264338327950288419716939937511") + e = BigDecimal("2.71828182845904523536028747135266249775724709369996") + pow = BigDecimal("22.459157718361045473") + assert_equal(pow, pi.power(e, 20)) + end + def test_limit BigDecimal.limit(1) x = BigDecimal.new("3") -- cgit v1.2.3