aboutsummaryrefslogtreecommitdiffstats
path: root/test/bigdecimal
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-05 16:34:59 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-05 16:34:59 +0000
commit2308fb170e5a1d1f6ad580fe3620d24d75069585 (patch)
treeec7684c025673727f10a0c8a45027689c9fa2de7 /test/bigdecimal
parent8cffe06a04e2107c765a32a0b8b8bbe2b02f2ef0 (diff)
downloadruby-2308fb170e5a1d1f6ad580fe3620d24d75069585.tar.gz
* ext/bigdecimal/bigdecimal.c (GetVpValueWithPrec):
treat 0.0 and -0.0 of floating-point numbers specially for an optimization and to correctly propagate its signbit to the result. [Bug #9214] [ruby-core:58858] * test/bigdecimal/test_bigdecimal.rb: add tests case for the above change. * test/bigdecimal/test_bigdecimal_util.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/bigdecimal')
-rw-r--r--test/bigdecimal/test_bigdecimal.rb3
-rw-r--r--test/bigdecimal/test_bigdecimal_util.rb6
2 files changed, 9 insertions, 0 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 8eb732aca1..6df858c7c4 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -86,6 +86,9 @@ class TestBigDecimal < Test::Unit::TestCase
assert_raise(ArgumentError) { BigDecimal(0.1) }
assert_raise(ArgumentError) { BigDecimal(0.1, Float::DIG + 2) }
assert_nothing_raised { BigDecimal(0.1, Float::DIG + 1) }
+
+ bug9214 = '[ruby-core:58858]'
+ assert_equal(BigDecimal(-0.0, Float::DIG).sign, -1, bug9214)
end
def test_global_new_with_big_decimal
diff --git a/test/bigdecimal/test_bigdecimal_util.rb b/test/bigdecimal/test_bigdecimal_util.rb
index 9a5d504abd..e4d64006ab 100644
--- a/test/bigdecimal/test_bigdecimal_util.rb
+++ b/test/bigdecimal/test_bigdecimal_util.rb
@@ -18,6 +18,9 @@ class TestBigDecimalUtil < Test::Unit::TestCase
assert_in_delta(BigDecimal(0.5, Float::DIG), 0.5.to_d, delta)
assert_in_delta(BigDecimal(355.0/113.0, Float::DIG), (355.0/113.0).to_d, delta)
assert_equal(9.05.to_d.to_s('F'), "9.05")
+
+ bug9214 = '[ruby-core:58858]'
+ assert_equal((-0.0).to_d.sign, -1, bug9214)
end
def test_Float_to_d_with_precision
@@ -25,6 +28,9 @@ class TestBigDecimalUtil < Test::Unit::TestCase
delta = 1.0/10**(digits)
assert_in_delta(BigDecimal(0.5, 5), 0.5.to_d(digits), delta)
assert_in_delta(BigDecimal(355.0/113.0, 5), (355.0/113.0).to_d(digits), delta)
+
+ bug9214 = '[ruby-core:58858]'
+ assert_equal((-0.0).to_d(digits).sign, -1, bug9214)
end
def test_Rational_to_d