Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/bigdecimal/bigdecimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3224,7 +3224,7 @@ rb_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception)
return rb_convert_to_BigDecimal(rb_complex_real(val), digs, raise_exception);
}
else if (RB_TYPE_P(val, T_STRING)) {
return rb_str_convert_to_BigDecimal(val, digs, raise_exception);
return rb_str_convert_to_BigDecimal(val, 0, raise_exception);
}

/* TODO: chheck to_d */
Expand All @@ -3238,7 +3238,7 @@ rb_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception)
}
return Qnil;
}
return rb_str_convert_to_BigDecimal(str, digs, raise_exception);
return rb_str_convert_to_BigDecimal(str, 0, raise_exception);
}

/* call-seq:
Expand Down
5 changes: 5 additions & 0 deletions test/bigdecimal/test_bigdecimal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ def test_BigDecimal
end
end

def test_BigDecimal_ignore_digits
assert_equal(1, BigDecimal(1, LIMITS["FIXNUM_MAX"]))
assert_equal(1, BigDecimal('1', LIMITS["FIXNUM_MAX"]))
end

def test_BigDecimal_bug7522
bd = BigDecimal("1.12", 1)
assert_same(bd, BigDecimal(bd))
Expand Down
Loading