* ext/bigdecimal/bigdecimal.c (BigDecimal_DoDivmod): fix precision.
[ruby-core:17472][ruby-dev:35372][ruby-dev:40105][ruby-dev:40358] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b4f90b236c
commit
03ad923cdd
@ -1,3 +1,8 @@
|
|||||||
|
Tue Feb 9 23:26:07 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* ext/bigdecimal/bigdecimal.c (BigDecimal_DoDivmod): fix precision.
|
||||||
|
[ruby-core:17472][ruby-dev:35372][ruby-dev:40105][ruby-dev:40358]
|
||||||
|
|
||||||
Tue Feb 9 22:23:27 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
Tue Feb 9 22:23:27 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
* io.c (READ_CHECK): do not select fd before reading, that had made
|
* io.c (READ_CHECK): do not select fd before reading, that had made
|
||||||
|
@ -970,8 +970,8 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod)
|
|||||||
return Qtrue;
|
return Qtrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
mx = a->Prec;
|
mx = a->Prec+abs(a->exponent);
|
||||||
if(mx<b->Prec) mx = b->Prec;
|
if(mx<b->Prec+abs(b->exponent)) mx = b->Prec+abs(b->exponent);
|
||||||
mx =(mx + 1) * VpBaseFig();
|
mx =(mx + 1) * VpBaseFig();
|
||||||
GUARD_OBJ(c,VpCreateRbObject(mx, "0"));
|
GUARD_OBJ(c,VpCreateRbObject(mx, "0"));
|
||||||
GUARD_OBJ(res,VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
|
GUARD_OBJ(res,VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
|
||||||
@ -983,6 +983,7 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod)
|
|||||||
VpAddSub(c,a,res,-1);
|
VpAddSub(c,a,res,-1);
|
||||||
if(!VpIsZero(c) && (VpGetSign(a)*VpGetSign(b)<0)) {
|
if(!VpIsZero(c) && (VpGetSign(a)*VpGetSign(b)<0)) {
|
||||||
VpAddSub(res,d,VpOne(),-1);
|
VpAddSub(res,d,VpOne(),-1);
|
||||||
|
GUARD_OBJ(d,VpCreateRbObject(GetAddSubPrec(c, b)*(VpBaseFig() + 1), "0"));
|
||||||
VpAddSub(d ,c,b, 1);
|
VpAddSub(d ,c,b, 1);
|
||||||
*div = res;
|
*div = res;
|
||||||
*mod = d;
|
*mod = d;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user