Skip to content

Commit e66cbd5

Browse files
committed
adjust the big-decimal fix
1 parent 9b8aa73 commit e66cbd5

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ public static RubyBigDecimal newInstance(IRubyObject recv, IRubyObject[] args) {
562562
return new RubyBigDecimal(runtime, (RubyClass)recv, new BigDecimal(((RubyFixnum)args[0]).getLongValue(), context));
563563
} else if (args[0] instanceof RubyBignum) {
564564
return new RubyBigDecimal(runtime, (RubyClass)recv, new BigDecimal(((RubyBignum)args[0]).getBigIntegerValue(), context));
565-
} else {
565+
} else if (!runtime.is1_8()) {
566566
context = MathContext.UNLIMITED;
567567
}
568568
// fall through to String coercion below

test/test_big_decimal.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,10 @@ def test_div_by_float_precision_gh648
262262
b = BigDecimal.new(1.05, 10)/1.48
263263
assert (b.to_f - 0.7094594594594595) < Float::EPSILON
264264
end
265+
266+
def test_GH_2650
267+
assert_equal(BigDecimal.new("10.91231", 1).to_f, 10.91231)
268+
assert_equal(BigDecimal.new("10.9", 2).to_f, 10.9)
269+
end
265270
end
266271
end

test/test_bignum.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'test/unit'
2-
require 'bigdecimal'
32

43
class TestBignum < Test::Unit::TestCase
54
# others tested in FixnumBignumAutoconversion test
@@ -42,11 +41,6 @@ def test_bignum_should_respond_to_array_operator
4241
def test_bignum_aref_with_bignum_arg_no_exception
4342
assert_equal(0, (2**64)[2**32])
4443
end
45-
46-
def test_GH_2650
47-
assert_equal(BigDecimal.new("10.91231", 1).to_f, 10.91231)
48-
assert_equal(BigDecimal.new("10.9", 2).to_f, 10.9)
49-
end
5044
# more to come
5145

5246
end

0 commit comments

Comments
 (0)