Skip to content

Commit

Permalink
adjust the big-decimal fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mkristian committed Mar 20, 2015
1 parent 9b8aa73 commit e66cbd5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Expand Up @@ -562,7 +562,7 @@ public static RubyBigDecimal newInstance(IRubyObject recv, IRubyObject[] args) {
return new RubyBigDecimal(runtime, (RubyClass)recv, new BigDecimal(((RubyFixnum)args[0]).getLongValue(), context));
} else if (args[0] instanceof RubyBignum) {
return new RubyBigDecimal(runtime, (RubyClass)recv, new BigDecimal(((RubyBignum)args[0]).getBigIntegerValue(), context));
} else {
} else if (!runtime.is1_8()) {
context = MathContext.UNLIMITED;
}
// fall through to String coercion below
Expand Down
5 changes: 5 additions & 0 deletions test/test_big_decimal.rb
Expand Up @@ -262,5 +262,10 @@ def test_div_by_float_precision_gh648
b = BigDecimal.new(1.05, 10)/1.48
assert (b.to_f - 0.7094594594594595) < Float::EPSILON
end

def test_GH_2650
assert_equal(BigDecimal.new("10.91231", 1).to_f, 10.91231)
assert_equal(BigDecimal.new("10.9", 2).to_f, 10.9)
end
end
end
6 changes: 0 additions & 6 deletions test/test_bignum.rb
@@ -1,5 +1,4 @@
require 'test/unit'
require 'bigdecimal'

class TestBignum < Test::Unit::TestCase
# others tested in FixnumBignumAutoconversion test
Expand Down Expand Up @@ -42,11 +41,6 @@ def test_bignum_should_respond_to_array_operator
def test_bignum_aref_with_bignum_arg_no_exception
assert_equal(0, (2**64)[2**32])
end

def test_GH_2650
assert_equal(BigDecimal.new("10.91231", 1).to_f, 10.91231)
assert_equal(BigDecimal.new("10.9", 2).to_f, 10.9)
end
# more to come

end

0 comments on commit e66cbd5

Please sign in to comment.