bigdecimal.c: more precision
* ext/bigdecimal/bigdecimal.c (BigDecimal_div2): need more room for precision to round. [ruby-core:77475] [Bug #12805] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1ae50df95d
commit
cc80f139cd
@ -1,3 +1,8 @@
|
|||||||
|
Tue Oct 4 09:55:12 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/bigdecimal/bigdecimal.c (BigDecimal_div2): need more room
|
||||||
|
for precision to round. [ruby-core:77475] [Bug #12805]
|
||||||
|
|
||||||
Tue Oct 4 06:05:46 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
Tue Oct 4 06:05:46 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* regcomp.c (onig_print_compiled_byte_code): make the shown address
|
* regcomp.c (onig_print_compiled_byte_code): make the shown address
|
||||||
|
@ -1533,7 +1533,7 @@ BigDecimal_div2(VALUE self, VALUE b, VALUE n)
|
|||||||
size_t mx = ix + VpBaseFig()*2;
|
size_t mx = ix + VpBaseFig()*2;
|
||||||
size_t pl = VpSetPrecLimit(0);
|
size_t pl = VpSetPrecLimit(0);
|
||||||
|
|
||||||
GUARD_OBJ(cv, VpCreateRbObject(mx, "0"));
|
GUARD_OBJ(cv, VpCreateRbObject(mx + VpBaseFig(), "0"));
|
||||||
GUARD_OBJ(av, GetVpValue(self, 1));
|
GUARD_OBJ(av, GetVpValue(self, 1));
|
||||||
GUARD_OBJ(bv, GetVpValue(b, 1));
|
GUARD_OBJ(bv, GetVpValue(b, 1));
|
||||||
mx = av->Prec + bv->Prec + 2;
|
mx = av->Prec + bv->Prec + 2;
|
||||||
|
@ -807,6 +807,12 @@ class TestBigDecimal < Test::Unit::TestCase
|
|||||||
BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY, false)
|
BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY, false)
|
||||||
assert_equal(0, BigDecimal("0").div(BigDecimal("Infinity")))
|
assert_equal(0, BigDecimal("0").div(BigDecimal("Infinity")))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
x = BigDecimal.new("1")
|
||||||
|
y = BigDecimal.new("0.22")
|
||||||
|
(2..20).each do |i|
|
||||||
|
assert_equal ("0."+"45"*(i/2)+"5"*(i%2)+"E1"), x.div(y, i).to_s, "#{i}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_abs_bigdecimal
|
def test_abs_bigdecimal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user